CQRS Design Pattern

A sample implementation of the command query responsibility segregation (CQRS) design pattern using AWS Step Functions

An AWS Step Functions workflow is used to route the incoming events and to route the Commands and Queries to respective branches within the workflow. To demonstrate CQRS Design Pattern, Commands and Queries has different data access patterns and uses different data sources.
Workflow is triggered by Amazon EventBridge events. Based on event properties, a state routes events to respective handlers. An order creation command is handled directly in the workflow and persisted in the Amazon DynamoDB table. Created orders are captured by an Amazon DynamoDB stream, transformed by an AWS Lambda function and stored in Amazon Aurora Serverless v2 MySQL-Compatible Edition database. Query events received are then routed to respective Lambda functions, which gets the data from Aurora Serverless v2 and sends the results to EventBridge.

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/cqrs/cd step-functions-workflows-collection/cqrs

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete.

Created by:

Tolga Orhon

Tolga Orhon

Senior Technical Account Manager at AWS, helping people to keep things running. I enjoy Serverless, Event Driven Architectures, Operational Excellence and Optimization.

Follow on LinkedIn