AWS Lambda durable functions to Amazon ECS with Python

AWS Lambda durable function → Amazon ECS

Invoke ECS tasks from Lambda durable functions with automatic checkpointing, state management, and resilient execution patterns

This pattern demonstrates AWS Lambda durable functions invoking Amazon ECS tasks with resilient, long-running execution capabilities:
1. Durable Synchronous Pattern: Lambda uses checkpointed steps and durable waits to poll ECS task status. Can run for up to 1 year with automatic recovery from failures. No compute charges during wait periods.
2. Durable Callback Pattern: Lambda uses checkpointed steps to reliably initiate ECS tasks. Each step (create record, start task, update status) is automatically checkpointed for guaranteed execution.
The pattern uses the AWS Durable Execution SDK for Python, providing automatic state management, checkpoint-based recovery, and cost-effective long-running workflows. Includes inline Python code in ECS containers, and VPC networking,

< 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-ecs-durable-python-sam

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

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