Scheduled Amazon EventBridge rule for AWS Lambda

EventBridge → AWS Lambda

Create an scheduled EventBridge rule that invokes a Lambda function

This CDK pattern deploys a custom scheduled EventBridge rule that triggers a Lambda function. An environment variable contains the value assigned to the interval (in minutes) that the Lambda function will run.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/eventbridge-scheduled-lambda-cdk-typescript/

Deploy

cdk deploy --context interval_in_minutes=<number>


Testing

After waiting for the interval period, go to the Lambda console.
Find the deployed Lambda function, and open the CloudWatch Logs. You will see a new log event every minute.

Cleanup

1. Delete the stack: npx cdk destroy.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus".
3. You see a message confirming DELETE_COMPLETE.

Created by:

Adilson Perinei

Adilson Perinei

AWS Cloud Application Architect with 6 AWS certifications. Adilson loves to develop application using AWS infrastructure using SAM.