Amazon EventBridge Scheduler is a serverless, reliable, and scalable way to schedule tasks in AWS. Think of it as AWS’s cron, but with more features and better integration.
Here’s EventBridge Scheduler in action. Let’s say we want to trigger a Lambda function every 15 minutes. We can use a cron expression for this.
aws scheduler create-schedule \
--name "MyFifteenMinuteLambdaTrigger" \
--group-name "MyTaskGroup" \
--schedule-expression "cron(*/15 * * * ? *)" \
--flexible-time-window Mode="OFF" \
--target '{
"Arn": "arn:aws:lambda:us-east-1:123456789012:function:MyLambdaFunction",
"RoleArn": "arn:aws:iam::123456789012:role/EventBridgeSchedulerRole",
"Input": "{\"message\": \"This is a scheduled task!\"}"
}'
This creates a schedule named MyFifteenMinuteLambdaTrigger within the MyTaskGroup. The schedule-expression is cron(*/15 * * * ? *), which means "at minutes 0, 15, 30, and 45 of every hour, every day of the month, every month, and every day of the week." The flexible-time-window Mode="OFF" ensures the task runs as close to the scheduled time as possible. The target specifies the Lambda function to invoke and provides a simple JSON input.
The core problem EventBridge Scheduler solves is the need for reliable, managed, and observable scheduled job execution without managing your own cron servers or EC2 instances. It integrates seamlessly with other AWS services, allowing you to trigger Lambda functions, send messages to SQS queues, publish to SNS topics, invoke Step Functions state machines, and more.
Internally, EventBridge Scheduler uses a distributed, fault-tolerant system to manage and execute your schedules. When you create a schedule, EventBridge Scheduler stores its configuration and uses internal clock synchronization mechanisms to determine when to trigger the target. It handles retries and error handling for you, making it much more robust than traditional cron.
The key levers you control are:
- Schedule Expression: This is the heart of your schedule. You can use cron expressions for complex, recurring schedules or
rateexpressions for simple interval-based schedules (e.g.,rate(1 hour)). - Target: This defines what EventBridge Scheduler will do when the schedule triggers. You specify the AWS service, the ARN of the resource, and any necessary input data or permissions.
- Flexible Time Window: This feature allows you to specify a window of time during which the scheduled task can run. This is useful for batch processing or when exact timing isn’t critical, but you want to spread the load. Setting
Mode="OFF"minimizes this window. - Dead-letter Queue (DLQ): For critical tasks, you can configure a DLQ (an SQS queue or SNS topic) to receive events that failed to be delivered or processed by the target after retries.
The most surprising thing about EventBridge Scheduler is how it handles time zones and daylight saving time automatically when you use cron expressions with a specified time zone. If you define your schedule in America/New_York and your cron expression is cron(0 2 * * ? *), EventBridge Scheduler will reliably trigger the task at 2 AM Eastern Time, adjusting for DST changes without any manual intervention from your side. This is a significant operational advantage over managing time-based events manually.
The next concept you’ll likely explore is how to manage the lifecycle of these schedules, including updating and deleting them, and how to configure retry policies for your targets.