TheArchitect

Step Functions Orchestration

AWS architecture template · SAA-C03: API Gateway → Step Functions → Lambda tasks + SQS + DynamoDB + SNS

Step Functions Orchestration is a free AWS architecture template built with Lambda, API Gateway, DynamoDB, IAM, SNS, SQS and Step Functions. Open it in TheArchitect to edit the diagram, estimate monthly cost, and export the CloudFormation or Terraform that deploys it.

API GatewayOrder ProcessorState Machine …Validate LambdaProcess LambdaFulfilment Que…Order TableNotifications
Step Functions Orchestration architecture diagram

AWS services in this template

  • Lambda×2
  • API Gateway
  • DynamoDB
  • IAM
  • SNS
  • SQS
  • Step Functions

Deployment notes

Needs input

  • Needs Lambda execution roles and a Step Functions RoleArn before the template is deploy-ready.
  • Generates an EXPRESS state machine with Lambda tasks, SQS queue, DynamoDB table, SNS notification, and IAM role.

Generated CloudFormation — 9 resources

Logical IDResource type
APIGatewayapigatewayAWS::ApiGateway::RestApi
OrderProcessorstepfunctionsAWS::StepFunctions::StateMachine
StateMachineRoleiamAWS::IAM::Role
ValidateLambdalambdaAWS::Lambda::Function
ProcessLambdalambdaAWS::Lambda::Function
FulfilmentQueuesqsAWS::SQS::Queue
OrderTabledynamodbAWS::DynamoDB::Table
NotificationssnsAWS::SNS::Topic
ProcessLambdalambdaFulfilmentQueuesqsEventSourceMappingAWS::Lambda::EventSourceMapping
View the full CloudFormation template
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Generated by TheArchitect — https://www.thecloudarchitect.dev",
  "Metadata": {
    "TheArchitect": {
      "Edges": [
        {
          "From": "StateMachineRoleiam",
          "To": "OrderProcessorstepfunctions",
          "Label": "role"
        },
        {
          "From": "ProcessLambdalambda",
          "To": "FulfilmentQueuesqs",
          "Label": "queue"
        },
        {
          "From": "ProcessLambdalambda",
          "To": "OrderTabledynamodb",
          "Label": "write"
        }
      ]
    }
  },
  "Resources": {
    "APIGatewayapigateway": {
      "Type": "AWS::ApiGateway::RestApi",
      "Properties": {
        "Name": "saa-orchestration-api",
        "Description": "REST API trigger for Step Functions workflows.",
        "EndpointConfiguration": {
          "Types": [
            "REGIONAL"
          ]
        }
      }
    },
    "OrderProcessorstepfunctions": {
      "Type": "AWS::StepFunctions::StateMachine",
      "DependsOn": [
        "StateMachineRoleiam"
      ],
      "Properties": {
        "StateMachineName": "saa-order-processor",
        "StateMachineType": "EXPRESS",
        "TracingConfiguration": {
          "Enabled": true
        },
        "LoggingConfiguration": {
          "Level": "ALL",
          "IncludeExecutionData": false
        }
      }
    },
    "StateMachineRoleiam": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "RoleName": "saa-order-processor-role",
        "Description": "IAM role granting Step Functions permission to invoke Lambda and SNS.",
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": "states.amazonaws.com"
              },
              "Action": "sts:AssumeRole"
            }
          ]
        }
      }
    },
    "ValidateLambdalambda": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Runtime": "nodejs20.x",
        "Handler": "index.handler",
        "MemorySize": 512,
        "Architectures": [
          "arm64"
        ],
        "Timeout": 30,
        "Description": "Validates order data against business rules.",
        "Environment": {
          "Variables": {
            "APP_ENV": "demo",
            "LOG_LEVEL": "info"
          }
        },
        "TracingConfig": {
          "Mode": "Active"
        },
        "Code": {
          "ZipFile": "exports.handler = async (event) => ({ statusCode: 200, body: JSON.stringify({ ok: true, requestId: event.requestContext?.requestId || 'demo' }) });"
        }
      }
    },
    "ProcessLambdalambda": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Runtime": "nodejs20.x",
        "Handler": "index.handler",
        "MemorySize": 512,
        "Architectures": [
          "arm64"
        ],
        "Timeout": 30,
        "Description": "Processes the validated order and queues fulfilment.",
        "Environment": {
          "Variables": {
            "APP_ENV": "demo",
            "LOG_LEVEL": "info"
          }
        },
        "TracingConfig": {
          "Mode": "Active"
        },
        "Code": {
          "ZipFile": "exports.handler = async (event) => ({ processed: Array.isArray(event.Records) ? event.Records.length : 1 });"
        }
      }
    },
    "FulfilmentQueuesqs": {
      "Type": "AWS::SQS::Queue",
      "Properties": {
        "QueueName": "saa-fulfilment-queue",
        "VisibilityTimeout": 120,
        "MessageRetentionPeriod": 345600,
        "ReceiveMessageWaitTimeSeconds": 20
      }
    },
    "OrderTabledynamodb": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "TableName": "saa-order-records",
        "BillingMode": "PAY_PER_REQUEST",
        "AttributeDefinitions": [
          {
            "AttributeName": "orderId",
            "AttributeType": "S"
          }
        ],
        "KeySchema": [
          {
            "AttributeName": "orderId",
            "KeyType": "HASH"
          }
        ],
        "PointInTimeRecoverySpecification": {
          "PointInTimeRecoveryEnabled": true
        },
        "SSESpecification": {
          "SSEEnabled": true
        }
      }
    },
    "Notificationssns": {
      "Type": "AWS::SNS::Topic",
      "Properties": {
        "TopicName": "saa-order-notifications",
        "DisplayName": "Order status notifications"
      }
    },
    "ProcessLambdalambdaFulfilmentQueuesqsEventSourceMapping": {
      "Type": "AWS::Lambda::EventSourceMapping",
      "DependsOn": [
        "ProcessLambdalambda",
        "FulfilmentQueuesqs"
      ],
      "Properties": {
        "EventSourceArn": {
          "Fn::GetAtt": [
            "FulfilmentQueuesqs",
            "Arn"
          ]
        },
        "FunctionName": {
          "Ref": "ProcessLambdalambda"
        },
        "Enabled": true,
        "BatchSize": 10
      }
    }
  }
}

Generated by TheArchitect from the diagram above. Review values such as names, CIDR ranges and instance sizes before deploying to your account.

Related templates