AWS Lambda durable functions with human-in-the-Loop

AWS Lambda → Amazon DynamoDB → Amazon SNS

Demonstrates Lambda durable functions with human approval workflow using Python, DynamoDB, and SNS

This pattern demonstrates how to pause Lambda execution, wait for human approval, and resume using the Lambda durable functions SDK.
The Workflow Lambda creates an approval request in DynamoDB and polls for decisions using durable waits (no compute charges during waits).
An SNS notification is sent to approvers, who can submit their decision via the Approval API Lambda function.
The Workflow Lambda detects the decision during polling and resumes execution with the approval result.
The pattern includes timeout handling, status tracking, and a complete audit trail of all approval decisions.

< 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/lambda-durable-hitl-python-sam

Deploy

sam buildsam deploy --guided


Testing

See the README in the GitHub repo for detailed testing instructions.
Test the approval workflow using AWS CLI:
1. Publish Lambda version: aws lambda publish-version --function-name
2. Invoke workflow: aws lambda invoke --function-name : --invocation-type Event --payload '{...}' response.json
3. List approvals: aws dynamodb scan --table-name
4. Submit decision: aws lambda invoke --function-name --payload '{"action":"decide",...}' response.json

Cleanup

Delete the stack: sam delete

Created by:

Mian Tariq

Mian Tariq

Mian is a Technical Lead / Senior Delivery Consultant at Amazon Web Services with dacades of experience in software development and enterprise architecture. He specializes in scalable systems, cloud transformations, and AI-driven solutions across industries. Mian focuses on aligning technology with business goals to deliver impactful, high-performnace results.

Follow on LinkedIn