Idempotent Workflow - SAM

A workflow that uses DynamoDB to implement idempotency

The workflow tracks the workflow execution and status in a DynamoDB table. When the workflow starts, an idempotency key is calculated based on the input event (customizable) and stored in the database as a semaphore together with a status of `IN_PROGRESS`.
If storing the key was successful, the workflow runs the actual workflow steps and records the result in the database with a status of `SUCCESS` (or `FAILED` in case of an error).
If acquiring the semaphore was not successful (i.e. the workflow successfully executed previously or another execution is running concurrently and thus the status is `IN_PROGRESS`) the workflow retrieves the idempotency record from the database. When the status is `SUCCESS` and there is a result the result is returned as output of the workflow. If the status is `IN_PROGRESS` the workflow continues to query the database every 10 seconds until the status changes to either `SUCCESS` and it continues as described above, or `FAILED`, in which case the workflow tries to acquire the semaphore again.

Launch Stack
< Back to all workflows

GitHub icon View this workflow on GitHub


Clone repo

git clone https://github.com/aws-samples/step-functions-workflows-collection/tree/main/idempotent-workflow-sam/cd step-functions-workflows-collection/idempotent-workflow-sam

Deploy

sam build --use-containersam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete.

Created by:

Daniel Moser

Daniel Moser

Daniel Moser is a Solutions Architect at Amazon Web Services (AWS). He specializes in serverless technologies and works with customers to build, architect, and design solutions that meet their business needs.