AWS Step Functions
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Callback Pattern Example

This sample project demonstrates how to have AWS Step Functions pause during a task, and wait for an external process to return a task token that was generated when the task started.

When this sample project is deployed and an execution is started, the following steps occur.

  1. Step Functions passes a message that includes a task token to an Amazon SQS queue.

  2. Step Functions then pauses, waiting for that token to be returned.

  3. The Amazon Simple Queue Service queue triggers an AWS Lambda function that calls SendTaskSuccess with that same task token.

  4. When the task token is received, the workflow continues.

  5. The "Notify Success" task publishes an Amazon SNS message that the callback was received.

To learn how to implement the callback pattern in Step Functions see Wait for a Callback with the Task Token.

To create the state machine and provision all resources

  1. Open the Step Functions console and choose Create a state machine.

  2. Choose Sample Projects, and then choose Callback Pattern Example.

    The state machine Code and Visual Workflow are displayed.

          Callback example workflow.
  3. Choose Create Sample Project.

    The Create Project Resources page is displayed, listing the resources that will be created. For this sample project the resources include:

    • An Amazon SQS message queue.

    • An AWS Lambda function, that calls the Step Functions API action SendTaskSuccess.

    • An Amazon SNS topic to notify success or failure when the workflow can continues.


    It can take up to 10 minutes for these resources and related IAM permissions to be created. While the Create Project Resources page displays Creating resources, you can open the Stack ID: link to see which resources are being provisioned.

    When complete, the New execution page is displayed.

  4. (Optional) Enter an execution name, and sample input.

          Start callback execution
  5. Choose Start Execution.

    A new execution of your state machine starts, and a new page showing your running execution is displayed.

          Callback execution
  6. To review how Step Functions progressed through the workflow and received a callback from Amazon SQS, review the entries in the Execution event history.