Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1.84 KB

File metadata and controls

58 lines (39 loc) · 1.84 KB

EventBridge: Schedule a Lambda function

Create an EventBridge scheduled rule that invokes a Lambda function every minute, verify execution in CloudWatch Logs, and clean up.

Source

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html

Use case

  • ID: eventbridge/getting-started
  • Phase: create
  • Complexity: beginner
  • Core actions: events:PutRule, events:PutTargets

What it does

  1. Creates an IAM execution role for Lambda
  2. Creates a Node.js Lambda function that logs EventBridge events
  3. Creates an EventBridge rule with a rate(1 minute) schedule
  4. Grants EventBridge permission to invoke the function
  5. Adds the Lambda function as the rule target
  6. Waits for the rule to fire and verifies output in CloudWatch Logs

Running

bash amazon-eventbridge-gs.sh

To auto-run with cleanup:

echo 'y' | bash amazon-eventbridge-gs.sh

Resources created

  • EventBridge rule (scheduled, rate 1 minute)
  • Lambda function (Node.js 22)
  • IAM role (with AWSLambdaBasicExecutionRole policy)
  • CloudWatch log group (created automatically by Lambda)

Estimated time

  • Run: ~90 seconds (includes 65s wait for rule to fire)
  • Cleanup: ~5 seconds

Cost

Free tier eligible. Lambda and EventBridge invocations stay well within free tier limits for this tutorial.

Related docs