New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gen2: Scheduled Lambdas are not possible anymore #1491
Comments
I managed it through CDK. Maybe you can adopt my suggested API for configuring Functions anyway 🙏? import { defineBackend } from '@aws-amplify/backend';
import * as cdk from 'aws-cdk-lib';
import * as events from 'aws-cdk-lib/aws-events';
import * as targets from 'aws-cdk-lib/aws-events-targets';
import { auth } from './auth/resource';
import { data } from './data/resource';
import { scheduledfunction } from './functions/scheduled-function/resource';
const backend = defineBackend({
auth,
data,
scheduledfunction,
});
// Create a new EventBridge rule that is triggered every hour
const rule = new events.Rule(
backend.scheduledfunction.resources.lambda,
'Rule',
{
description: 'Rule that triggers the lambda function every hour',
schedule: events.Schedule.rate(cdk.Duration.hours(1)),
},
);
// Add the lambda function as a target for the rule
rule.addTarget(
new targets.LambdaFunction(backend.scheduledfunction.resources.lambda),
); |
Hey @jgo80, thank you for reaching out. Marking this as feature request. |
That's what I exactly what I was looking into. Thank you so much for sharing this. |
Worth noting that gen1 used Cloudwatch Events. This feature has been sunset by AWS. Trying to create a Cloudwatch event in the AWS console will now redirect customers to create an EventBridge rule. As such, if just wanting a way to mirror the behavior found in gen1, the answer provided by the OP is the solution. For a more feature rich experience in creating scheduled tasks, either one time or recurring, EventBridge Scheduler is a better solution. This blog posts explains the differences: https://aws.amazon.com/blogs/compute/introducing-amazon-eventbridge-scheduler/ |
Before opening, please confirm:
JavaScript Framework
Not applicable
Amplify APIs
Not applicable
Amplify Version
v6
Amplify Categories
function
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
In Gen 2 "Scheduled Lambdas" are not possible anymore. How do do it?
The Documentation introduces Functions to be capable of Scheduled jobs, but there is no hint how to achieve it.
The situation feels very unpleasant. The documentation clearly recommends switching from Gen 1 to Gen 2 and raises fears that Gen 1 will not be available forever. At the same time, fundamental functions are missing (for the moment?) in Gen 2.
Expected behavior
I would love to see something like this:
Reproduction steps
Feature is missing, no reproduction
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: