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