Saga pattern with AWS Lambda durable functions in Node.js

Saga Orchestrator (Durable)

Implement the Saga pattern for distributed transactions using AWS Lambda durable functions with automatic compensating transactions

This pattern demonstrates the Saga pattern using AWS Lambda durable functions to coordinate distributed transactions across multiple services.
The orchestrator function executes a sequence of reservation steps (flight, hotel, car). Each step is checkpointed automatically using context.step().
If any step fails, compensating transactions execute in reverse order to rollback all completed operations, ensuring data consistency.
The durable function maintains execution state without requiring external storage like DynamoDB or Step Functions.

< 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-functions-nodejs-saga-pattern

Deploy

sam buildsam deploy --guided


Testing

See the README in the GitHub repo for detailed testing instructions.

Cleanup

sam delete --stack-name saga-pattern-demo

Created by:

Surya Sai D

Surya Sai D

Surya works as a Technical Account Manager at AWS. He is an expert in Serverless frameworks and Event Driven Architectures. Surya is also passionate on technical writing and has contributed to AWS blogs and other Open Source Content.

Follow on LinkedIn