How to pause a Step Function while waiting for a response from a third-party API or other services for up to one year.

How to pause a Step Function while waiting for a response from a third-party API or other services for up to one year.

 

You can pause a Step Function task indefinitely using Task Tokens. This is useful when the task needs to wait for human approval or interact with a third party.

When a task in your state machine is set as a callback task using .waitForTaskToken, a Task Token is generated for that task. This token is placed in the context object of the Step Function when the task starts.

It should be noted that Task Tokens are region and account specific. They are valid up to 1 year, however a new task token will be regenerated automatically if the task state using the callback task token times out.

  • This can be done by selecting the "Wait for callback" option in Workflow Studio for your chosen task.

Article content

This action appends .waitForTaskToken to the resource of the state definition in the Step Function's ASL file like this:

Article content

  • For example, we are waiting for the response from a lambda.In order to access the task token inside a lambda we have to take it from the context object and pass it in with our input as the lambda payload. The state definition will look as follows:

Article content


To view or add a comment, sign in

More articles by Mahmudul Hasan

  • Web Accessibility

    HTML accessibility refers to designing and coding websites so that everyone, including people with disabilities, can…

    2 Comments
  • Debounce function in JavaScript

    📝 The debounce() function forces a function to wait a certain amount of time against an event. When an event occurs…

  • Difference between Shallow copy and Deep copy in Python

    First of all, we will discuss about cloning concept in python. See the following example.

Insights from the community

Others also viewed

Explore topics