Remove one-time Amazon EventBridge schedules after they run

Scheduler → AWS Lambda → SQS → AWS Lambda

Simple pattern to remove one-time schedules after 2 days of their execution.

Creates a schedule that is run every day at 00:00 that checks for one-time schedules. If any schedules are found it removes them.
How the pattern works
Schedule is triggered every day at 00:00. Lambda is triggered to get schedules and put them on an SQS queue for processing. When schedules are processed they are checked to see if they are one-time schedules and have `expired` (2 days after they have run (which can be configured)).
When matches are found, they are deleted from your AWS account.
The EventBridge team are looking at more permenant solutions to this problem, but you can use this pattern to help.
Things to consider
If you have thousands of one-time schedules you might need to change this pattern slightly to handle API throttling you may occur.
Pattern does not know if your schedule has been run or not. Assumptions are made that it has and will remove them once the configured time period has passed.

< 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-schedule-remove-one-time-schedules

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

David Boyne

David Boyne

Helping people learn about event-driven architectures and serverless

Follow on LinkedIn