Skip to content

Blueprint for implementing the SAGA pattern in an e-commerce application using AWS Step Functions

License

Notifications You must be signed in to change notification settings

aliliarif/saga-step-functions

Repository files navigation

Saga Pattern Implementation with AWS Step Functions

Overview

This repository contains the source code for orchestrating microservices using the Saga Pattern with AWS Step Functions. The blueprint demonstrates implementing the Saga Pattern in an e-commerce application using AWS Step Functions.

In this blog post, you can read more about Saga pattern and composable commerce example walkthrough

Project structure

  • infrastructure Contains infrastructure code written with AWS SAM, defined in template.yml.
  • lambdas: Contains all AWS Lambda function source code.

Prerequisites

  • AWS account with access to AWS Step Functions, Lambda, and other necessary services.
  • Node.js for changing AWS Lambda functions' code
  • AWS CLI installed and configured.
  • SAM

Setup

Step 1: Clone the Repository

git clone https://github.com/aliliarif/saga-step-functions

Step 2: Install Dependencies

cd saga-step-functions
npm install

Step 3: Deploy

cd infrastructure
sam build
sam deploy --guided --capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND

Payload to test the State Machine

Sample JSON for Order process failure

{
  "body": "{\"failCreateOrder\": true}"
}

Image of Failed Order Creation

Sample JSON for Inventory update failure

{
  "body": "{\"failInventoryUpdate\": true}"
}

Image of Failed Inventory Update

Sample JSON for Payment process failure

{
  "body": "{\"failProcessPayment\": true}"
}

Image of Failed Process Payment

Cleanup

Clean up the resources deployed by SAM project

cd infrastructure
sam delete

References

About

Blueprint for implementing the SAGA pattern in an e-commerce application using AWS Step Functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published