Application Integration on AWS: Step Functions, SQS, SNS, EventBridge and API Patterns
Four Basic Patterns
| Pattern | Service | Idea |
|---|---|---|
| Queue (buffer) | SQS | Producer drops work, consumers process at their pace |
| Pub/sub (fan-out) | SNS | One message, many subscribers |
| Event routing | EventBridge | Rules send matching events to targets |
| Workflow (orchestration) | Step Functions | A visual state machine runs steps in order with retries |
You met SQS, SNS and EventBridge earlier. This lesson adds Step Functions and shows how to choose.
AWS Step Functions
- Build workflows that coordinate Lambda functions and over 200 AWS services
- Defined in Amazon States Language (JSON) or drawn in Workflow Studio
- Handles retries, error catching, waiting, parallel branches and human approval
- Standard workflows: long running (up to 1 year), exactly-once. Express workflows: short, very high volume, cheaper per run
| State type | Use |
|---|---|
| Task | Do work (invoke Lambda, call a service) |
| Choice | If / else branching |
| Parallel | Run branches at the same time |
| Map | Do the same step for each item in a list |
| Wait | Pause for time or until a date |
| Pass / Succeed / Fail | Pass data, finish OK, finish with error |
json
{
"Comment": "Order workflow",
"StartAt": "ValidateOrder",
"States": {
"ValidateOrder": {"Type": "Task", "Resource": "arn:aws:lambda:ap-south-1:111111111111:function:validate", "Next": "InStock?",
"Retry": [{"ErrorEquals": ["States.TaskFailed"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2}],
"Catch": [{"ErrorEquals": ["States.ALL"], "Next": "OrderFailed"}]},
"InStock?": {"Type": "Choice", "Choices": [{"Variable": "$.inStock", "BooleanEquals": true, "Next": "ChargeCard"}], "Default": "OrderFailed"},
"ChargeCard": {"Type": "Task", "Resource": "arn:aws:lambda:ap-south-1:111111111111:function:charge", "Next": "NotifyCustomer"},
"NotifyCustomer": {"Type": "Task", "Resource": "arn:aws:states:::sns:publish", "Parameters": {"TopicArn": "arn:aws:sns:ap-south-1:111111111111:orders", "Message.$": "$.message"}, "End": true},
"OrderFailed": {"Type": "Fail", "Error": "OrderError", "Cause": "Validation or payment failed"}
}
}
bash
aws stepfunctions create-state-machine --name order-flow --definition file://flow.json --role-arn arn:aws:iam::111111111111:role/StepFunctionsRole
aws stepfunctions start-execution --state-machine-arn arn:aws:states:ap-south-1:111111111111:stateMachine:order-flow --input '{"inStock": true, "message": "Order received"}'
aws stepfunctions list-executions --state-machine-arn arn:aws:states:ap-south-1:111111111111:stateMachine:order-flow --max-items 5
Choosing the Right Tool
| Need | Choose |
|---|---|
| Smooth out spikes, retry failed jobs | SQS (with DLQ) |
| Notify many systems at once | SNS |
| React to AWS events or SaaS events, schedules | EventBridge |
| Multi-step process with branching and retries | Step Functions |
| Real-time streaming data | Kinesis or MSK |
| Migrate apps that use ActiveMQ or RabbitMQ | Amazon MQ |
| GraphQL API for apps | AWS AppSync |
| Create REST APIs | API Gateway |
Choreography vs Orchestration
- Choreography: services react to events on their own (SNS, EventBridge). Flexible but harder to see the whole flow
- Orchestration: one coordinator (Step Functions) controls the order. Easier to follow and debug
Practice
- Create the sample state machine with Pass states and run it
- Add a Retry and a Catch to a Lambda task
- Use a Map state to process a list
- Build SNS to SQS fan-out with two queues
Conclusion
Use SQS to buffer, SNS to fan out, EventBridge to route events and Step Functions to orchestrate multi-step workflows with retries. Pick by the need, not by habit.
Quick Summary: patterns; Step Functions; choosing; choreography vs orchestration.

