Step Functions: Orchestrating Serverless Workflows
Define multi-step workflows as state machines in Step Functions, handle errors with catch and retry blocks, and integrate native SDK integrations.
What Are AWS Step Functions?
AWS Step Functions is a fully managed workflow orchestration service that coordinates distributed applications as a series of steps defined in a state machine. Each step in the state machine is a state — a Lambda invocation, an AWS SDK call, a wait period, a parallel branch, or a choice (if/else). Step Functions manages state, handles retries, and provides a visual execution history, eliminating the need to write orchestration logic in application code.
Amazon States Language (ASL)
State machines are defined in Amazon States Language (ASL), a JSON-based language. Each state has a Type (Task, Choice, Wait, Parallel, Map, Pass, Succeed, Fail) and transitions to a Next state or ends. The Resource field of a Task state specifies the AWS service to invoke — an ARN for Lambda, or an optimised service integration ARN for over 200 AWS services without an intermediate Lambda.
{
'Comment': 'Order processing workflow',
'StartAt': 'ValidateOrder',
'States': {
'ValidateOrder': {
'Type': 'Task',
'Resource': 'arn:aws:lambda:us-east-1:123456789012:function:ValidateOrder',
'Next': 'ChargePayment',
'Retry': [{'ErrorEquals': ['Lambda.ServiceException'], 'IntervalSeconds': 2, 'MaxAttempts': 3}]
},
'ChargePayment': {
'Type': 'Task',
'Resource': 'arn:aws:states:::dynamodb:putItem',
'Parameters': {'TableName': 'Orders', 'Item': {'orderId': {'S.$': '$.orderId'}}},
'End': true
}
}
}All lessons in this course
- EventBridge: Event Bus and Rules
- Step Functions: Orchestrating Serverless Workflows
- Kinesis Data Streams for Real-Time Event Processing
- Choreography vs Orchestration Patterns