Sub topic 15
Scheduled invocations and EventBridge Scheduler
This chapter assumes you can create rules and targets with the AWS CLI, read JSON, and understand IAM roles. Earlier chapters covered events that a producer sends. Here the trigger is the clock.
Two ways to run something on a schedule
AWS offers two services for time-based invocations:
- Scheduled rules are EventBridge rules with a schedule expression instead of an event pattern. They live on an event bus, usually the default bus, and use the same targets, retry policy, and dead-letter queue settings you already know.
- EventBridge Scheduler is a separate service built for scheduling at scale. It supports one-time schedules, time zones, flexible time windows, and many more schedules per account.
For new work, AWS recommends EventBridge Scheduler. Scheduled rules still work and are common in existing systems.
Schedule expressions
Both services accept two expression types.
| Type | Example | Meaning |
|---|---|---|
| Rate | `rate(5 minutes)` | Every 5 minutes. Use `minute`, `hour`, or `day`. Use the singular when the value is 1, such as `rate(1 hour)`. |
| Cron | `cron(0 8 ? * MON-FRI *)` | 08:00 on weekdays. It has six fields: minutes, hours, day-of-month, month, day-of-week, year. |
In cron, you must put ? in either the day-of-month or the day-of-week field. Scheduled rules always evaluate cron in UTC. Scheduler lets you set a time zone, so cron(0 8 ? * MON-FRI *) can mean 08:00 in Europe/Paris and follow daylight saving changes.
Scheduler also supports a one-time expression, at(2026-12-01T09:00:00).
Creating a scheduled rule
A scheduled rule uses --schedule-expression instead of --event-pattern.
aws events put-rule --name nightly-cleanup --schedule-expression "cron(0 2 * * ? *)"
aws events put-targets --rule nightly-cleanup --targets "Id"="cleanup-fn","Arn"="arn:aws:lambda:us-east-1:123456789012:function:cleanup"The Lambda function also needs a resource-based permission that lets events.amazonaws.com invoke it, as described in the permissions chapter. The event that reaches the target is a generic Scheduled Event with source aws.events. It carries the rule ARN and a timestamp, not your own data. Use a constant input on the target if you need to pass parameters.
Creating a schedule in EventBridge Scheduler
Scheduler uses its own CLI namespace, aws scheduler. It does not use a bus or an event pattern. Each schedule has one target, and it assumes an IAM role that you supply to invoke that target.
aws scheduler create-schedule \
--name nightly-cleanup \
--schedule-expression "cron(0 2 * * ? *)" \
--schedule-expression-timezone "Europe/Paris" \
--flexible-time-window Mode=OFF \
--target '{"Arn":"arn:aws:lambda:us-east-1:123456789012:function:cleanup","RoleArn":"arn:aws:iam::123456789012:role/scheduler-invoke-cleanup","Input":"{\"mode\":\"full\"}"}'The role needs lambda:InvokeFunction on the function, and its trust policy must allow scheduler.amazonaws.com to assume it. The Input string is delivered to the target as the payload.
--flexible-time-window is required. Setting Mode=OFF invokes at the exact time. Setting Mode=FLEXIBLE with MaximumWindowInMinutes=15 spreads invocations across a window, which reduces load spikes when many schedules share the same time.
Choosing between them
| Need | Better choice |
|---|---|
| A time zone, or one-time schedules | Scheduler |
| Thousands of per-customer or per-task schedules | Scheduler |
| A schedule that sits next to bus rules in existing infrastructure | Scheduled rule |
| Event pattern matching | Rule on a bus |
Scheduler retries failed invocations and supports a dead-letter queue, so the reliability ideas from the retries chapter carry over.
Exercise
You need a job to run at 09:00 every weekday in America/New_York, adjusting automatically for daylight saving time. Which service and settings do you use?
Show answer
Use EventBridge Scheduler with cron(0 9 ? * MON-FRI *) and --schedule-expression-timezone "America/New_York". A scheduled rule cannot do this because it evaluates cron only in UTC.
Exercise
A schedule created with aws scheduler create-schedule is accepted, but the Lambda function is never invoked. Name the two IAM pieces you check first.
Show answer
Check that the role in the target's RoleArn allows lambda:InvokeFunction on the function. Then check that its trust policy lets scheduler.amazonaws.com assume the role.