AWS Step Functions β Serverless Workflows
AWS Step Functions β Serverless Workflows
Section titled βAWS Step Functions β Serverless WorkflowsβAWS Step Functions is a serverless workflow orchestration service that lets you coordinate multiple AWS services into resilient multi-step applications using visual state machines.
In Azure terms: Step Functions β Azure Logic Apps / Azure Durable Functions
Why Step Functions?
Section titled βWhy Step Functions?βWithout orchestration, complex workflows in Lambda lead to:
- Spaghetti code with one Lambda calling another
- Lost state between steps
- No visibility into where a workflow failed
- Difficult retry and error handling logic
Step Functions solves this with a declarative state machine where you define states, transitions, retries, and error handling in JSON (Amazon States Language).
Workflow Types
Section titled βWorkflow Typesβ| Type | Description | Execution limit | Pricing |
|---|---|---|---|
| Standard | Exactly-once execution, full audit history | 1 year | Per state transition |
| Express | At-least-once, high throughput | 5 minutes | Per execution + duration |
Use Standard for business-critical workflows. Use Express for high-volume event processing (IoT, streaming).
Amazon States Language (ASL)
Section titled βAmazon States Language (ASL)βStep Functions workflows are defined in JSON:
{ "Comment": "Order processing workflow", "StartAt": "ValidateOrder", "States": { "ValidateOrder": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123:function:validate-order", "Next": "ProcessPayment", "Retry": [{ "ErrorEquals": ["States.TaskFailed"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2 }], "Catch": [{ "ErrorEquals": ["InvalidOrderError"], "Next": "HandleInvalidOrder" }] }, "ProcessPayment": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123:function:process-payment", "Next": "SendConfirmation" }, "SendConfirmation": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123:function:send-email", "End": true }, "HandleInvalidOrder": { "Type": "Fail", "Cause": "Order validation failed" } }}State Types
Section titled βState Typesβ| State Type | Description |
|---|---|
| Task | Execute a Lambda, ECS task, SNS publish, DynamoDB call, etc. |
| Choice | Branch based on conditions (like if/else) |
| Wait | Pause for a fixed time or until a timestamp |
| Parallel | Run multiple branches simultaneously |
| Map | Process each item in an array concurrently |
| Pass | Pass input to output (useful for testing or adding data) |
| Succeed | End the execution successfully |
| Fail | End the execution with an error |
SDK Integrations (No Lambda Needed)
Section titled βSDK Integrations (No Lambda Needed)βStep Functions can call AWS services directly without a Lambda wrapper:
- DynamoDB (GetItem, PutItem, UpdateItem)
- S3 (GetObject, PutObject)
- SQS (SendMessage)
- SNS (Publish)
- ECS (RunTask)
- SageMaker (training jobs)
- Bedrock (LLM invocations)
- HTTP endpoints (any REST API)
Patterns
Section titled βPatternsβSequential Pipeline
Section titled βSequential PipelineβStep 1 β Step 2 β Step 3 β DoneParallel Execution
Section titled βParallel Executionβ ββ Step A ββStart ββββββ€β Step B βββββ Merge β Done ββ Step C ββFan-Out (Map State)
Section titled βFan-Out (Map State)β[item1, item2, item3] β Process all in parallel β Collect resultsHuman Approval (Wait for Token)
Section titled βHuman Approval (Wait for Token)βStep Functions supports callback patterns where a workflow pauses until a human or external system sends a task token back:
Step Functions sends token to SQSβ Worker processes and sends approval/rejection backβ Workflow continuesStep Functions vs Azure Logic Apps
Section titled βStep Functions vs Azure Logic Appsβ| Feature | Step Functions | Azure Logic Apps |
|---|---|---|
| Visual designer | Yes (AWS Console + VS Code) | Yes (designer + code view) |
| Connectors | SDK integrations (AWS services) + HTTP | 1,000+ connectors (Outlook, SAP, Salesforce) |
| Code-based workflow | Yes (ASL JSON) | Yes (workflow JSON) |
| Error handling | Retry + Catch per state | Try/Catch blocks |
| Branching | Choice state | Condition, Switch actions |
| Fan-out | Map state | ForEach loop |
| Human approval | Callback pattern | Approval email action |
| Pricing | Per state transition | Per action execution |
CLI Examples
Section titled βCLI Examplesβ# Create a state machineaws stepfunctions create-state-machine \ --name order-workflow \ --definition file://workflow.json \ --role-arn arn:aws:iam::123456789:role/step-functions-role \ --type STANDARD
# Start an executionaws stepfunctions start-execution \ --state-machine-arn arn:aws:states:us-east-1:123456789:stateMachine:order-workflow \ --input '{"orderId": "ord-001", "amount": 99.99}'
# List executionsaws stepfunctions list-executions \ --state-machine-arn arn:aws:states:us-east-1:123456789:stateMachine:order-workflow
# Describe an executionaws stepfunctions describe-execution \ --execution-arn arn:aws:states:us-east-1:123456789:execution:order-workflow:abc-123