code for article pfeilbr/amazon-eventbridge-scheduler-playground
learn Introducing Amazon EventBridge Scheduler
General
- new service name
scheduler
(actionsscheduler:*
)
Key features of EventBridge Scheduler
- Templated targets – EventBridge Scheduler supports templated targets to perform common API operations using Amazon SQS, Amazon SNS, Lambda, and EventBridge. With predefined targets, you can configure your schedules quickly using the EventBridge Scheduler console, the EventBridge Scheduler SDK, or the AWS CLI.
- Universal targets – EventBridge Scheduler provides a universal target parameter (UTP) that you can use to create customized triggers that target more than 270 AWS services and over 6,000 API operations on a schedule. With UTP, you can configure your customized triggers using the EventBridge Scheduler console, the EventBridge Scheduler SDK, or the AWS CLI.
- Flexible time windows – EventBridge Scheduler supports flexible time windows, allowing you to disperse your schedules and improve the reliability of your triggers for use cases that do not require precise scheduled invocation of targets.
- Retries – EventBridge Scheduler provides at-least-once event delivery to targets, meaning that at least one delivery succeeds with a response from the target. EventBridge Scheduler allows you to set the number of retries for your schedule for a failed task. EventBridge Scheduler retries failed tasks with delayed attempts to improve the reliability of your schedule and ensure targets are available.
Demo
aws scheduler create-schedule --name SendEmailOnce \
--schedule-expression "at(2022-11-01T11:00:00)" \
--schedule-expression-timezone "Europe/Helsinki" \
--flexible-time-window "{\"Mode\": \"OFF\"}" \
--target "{\"Arn\": \"arn:aws:sns:us-east-1:xxx:test-chronos-send-email\", \"RoleArn\": \" arn:aws:iam::xxxx:role/sam_scheduler_role\" }"
Bash
there is a SAM event type of Type: ScheduleV2
that can trigger lambda or state machine
MyFunction:
Type: AWS::Serverless::Function
Properties:
Events:
CWSchedule:
Type: ScheduleV2
Properties:
Schedule: 'rate(1 minute)'
Name: TestScheduleV2Function
Description: Test schedule event
MyStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Events:
CWSchedule:
Type: ScheduleV2
Properties:
Schedule: 'rate(1 minute)'
Name: TestScheduleV2StateMachine
Description: Test schedule event
Differences between EventBridge Scheduler and EventBridge rules
Resources
- Introducing Amazon EventBridge Scheduler
- Amazon EventBridge Scheduler - Launch Announcement (twitter)
- Scheduler User Guide
- Scheduling events with EventBridge Scheduler
- Amazon EventBridge Scheduler resource type reference
- AWS::Scheduler::Schedule
- AWS::Scheduler::ScheduleGroup
Twitter • Reddit