DEV Community

Cover image for Manage EventBridge Schedules using Step Functions
Pubudu Jayawardana for AWS Community Builders

Posted on • Originally published at Medium


Manage EventBridge Schedules using Step Functions

AWS Step functions recently announced SDK support for another 35 services.


This includes the support for EventBridge Scheduler as well. One time schedule is one of the great features supported by EventBridge Scheduler. As the name implies, it allows you to schedule a task just to run once at a given time.

As at now ( February 2023) EventBridge Scheduler doesn't have native functionality to know if the target task is successful or not. Also schedule will not be deleted itself automatically after the execution is completed at the given time.

In this blog I explain a simple use case where we can create one time schedules and later remove them after the execution using Step Functions using new SDK integrations.

Step Functions State Machine

State Machine

How it works

  1. On the Step Functions execution, it first creates a one time schedule using EventBridge Scheduler SDK integration.

  2. This Schedule has a target lambda function.

  3. The schedule creation step in the state machine is configured with the call back pattern. So it waits until Step Functions receives a Task Success or Failure signal.

  4. At the set time, the Scheduler will trigger the lambda function.

  5. Within the Lambda function, based on Success or error in the business logic, task success or task failed Step Functions API can be called.

  6. Once Step Functions receives the callback it sends a message to a predefined SNS topic with the result. By subscribing to this SNS topic, you may continue on the business logic as to what to do based on the result.

  7. In the next step of Step Functions execution, the schedule will be deleted.

Few limitations

  1. Since callback pattern is only available for Step Functions standard flows, this solution works only within a standard flow.

  2. With this, you can only schedule only up to one year ahead. Because the maximum duration a standard flow can run is one year.

Want to test yourself?

I have created a sample project for you to test this scenario in your AWS account. You need AWS CLI, SAM CLI and GIT installed in your machine.

Below are the deployment details.

  1. Clone the repository:

  2. Go into the directory manage-eb-schedules-with-stepfunctions

  3. Install dependencies with sam build

  4. Deploy the stack with sam deploy -g

  5. Once the stack is deployed successfully, you can start a Step Functions execution with below payload format:

  "scheduleDate": "YYYY-MM-DD",
  "scheduleTime": "hh:mm:ss",
  "error": 0
Enter fullscreen mode Exit fullscreen mode

To test the scheduled task failure scenario, set the error value to 1.

To delete the stack, use: sam delete


In this use case, you can create one time schedules in EventBridge Scheduler and wait until it runs, then delete them once it is completed. All can be handled within a Step Functions execution as a low code solution.


  1. Introducing Amazon EventBridge Scheduler
  2. Amazon EventBridge Scheduler Docs
  3. Amazon EventBridge One Time Schedules

** Cover Photo by Lucian Alexe on Unsplash

Top comments (2)

lasanthasilva profile image
Lasantha Sanjeewa Silva

Awesome Article

pubudusj profile image
Pubudu Jayawardana

Thanks Lasantha