Top 20 AWS Step Functions Interview Questions
- What is AWS Step Functions?
- What are Step Functions workflow types?
- What is Amazon States Language (ASL)?
- What are the different state types?
- How do you handle errors in Step Functions?
- What are Task states?
- How do you implement parallel execution?
- What are Map states?
- How do you manage data flow between states?
- What are intrinsic functions?
- How do you implement human approval workflows?
- What are service integrations?
- How do you handle long-running tasks?
- What are execution events and history?
- How do you implement versioning?
- What are Step Functions best practices?
- How do you test Step Functions?
- What is Step Functions Express vs Standard?
- How do you monitor Step Functions?
- What are common Step Functions patterns?
AWS Interview Questions - All Topics
1. What is AWS Step Functions?
AWS Step Functions is a serverless workflow orchestration service for coordinating distributed applications and microservices.
Step Functions Features:
âââ Visual workflow designer
âââ Built-in error handling
âââ State management
âââ Service integrations (200+)
âââ Parallel and sequential execution
âââ Audit and execution history
Use Cases:
âââ ETL/Data pipelines
âââ Microservice orchestration
âââ Human approval workflows
âââ IT automation
âââ Machine learning pipelines
âââ Order processing
# Simple workflow example
{
"Comment": "A simple sequential workflow",
"StartAt": "FirstState",
"States": {
"FirstState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:MyFunction",
"Next": "SecondState"
},
"SecondState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:AnotherFunction",
"End": true
}
}
}
2. What are Step Functions workflow types?
| Feature | Standard | Express |
|---|---|---|
| Duration | Up to 1 year | Up to 5 minutes |
| Execution rate | 2,000/sec | 100,000/sec |
| Pricing | Per state transition | Per execution + duration |
| Execution history | Full history | CloudWatch Logs |
| Use case | Long-running | High-volume, short |
# Create Standard workflow
import boto3
sfn = boto3.client('stepfunctions')
sfn.create_state_machine(
name='StandardWorkflow',
definition=json.dumps(workflow_definition),
roleArn='arn:aws:iam::123456789012:role/StepFunctionsRole',
type='STANDARD'
)
# Create Express workflow
sfn.create_state_machine(
name='ExpressWorkflow',
definition=json.dumps(workflow_definition),
roleArn='arn:aws:iam::123456789012:role/StepFunctionsRole',
type='EXPRESS',
loggingConfiguration={
'level': 'ALL',
'includeExecutionData': True,
'destinations': [{
'cloudWatchLogsLogGroup': {
'logGroupArn': 'arn:aws:logs:us-east-1:123456789012:log-group:express-logs'
}
}]
}
)
Express Workflow Modes:
âââ Synchronous: Wait for result (API Gateway)
âââ Asynchronous: Fire and forget
3. What is Amazon States Language (ASL)?
ASL is a JSON-based language for defining Step Functions state machines.
ASL Structure:
{
"Comment": "Description of workflow",
"StartAt": "FirstStateName",
"TimeoutSeconds": 3600,
"Version": "1.0",
"States": {
"FirstStateName": {
"Type": "Task|Pass|Choice|Wait|Succeed|Fail|Parallel|Map",
"Comment": "State description",
"InputPath": "$.input",
"OutputPath": "$.output",
"ResultPath": "$.result",
"Parameters": {},
"ResultSelector": {},
"Next": "NextStateName",
"End": true
}
}
}
Key Fields:
âââ StartAt: First state to execute
âââ States: Map of state definitions
âââ Type: State type (Task, Choice, etc.)
âââ Next: Next state to transition to
âââ End: Marks terminal state
âââ InputPath: Filter input data
âââ OutputPath: Filter output data
âââ ResultPath: Where to place result
âââ Parameters: State input parameters
# Complete example
{
"Comment": "Order processing workflow",
"StartAt": "ValidateOrder",
"States": {
"ValidateOrder": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:validate",
"Next": "CheckInventory",
"Catch": [{
"ErrorEquals": ["ValidationError"],
"Next": "OrderFailed"
}]
},
"CheckInventory": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:inventory",
"Next": "ProcessPayment"
},
"ProcessPayment": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:payment",
"Next": "OrderComplete"
},
"OrderComplete": {
"Type": "Succeed"
},
"OrderFailed": {
"Type": "Fail",
"Error": "OrderProcessingFailed",
"Cause": "Order validation failed"
}
}
}
4. What are the different state types?
State Types:
1. Task - Execute work
{
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:MyFunction",
"Next": "NextState"
}
2. Pass - Pass input to output (no-op)
{
"Type": "Pass",
"Result": {"status": "processed"},
"ResultPath": "$.metadata",
"Next": "NextState"
}
3. Choice - Conditional branching
{
"Type": "Choice",
"Choices": [
{
"Variable": "$.status",
"StringEquals": "approved",
"Next": "ProcessApproved"
},
{
"Variable": "$.amount",
"NumericGreaterThan": 1000,
"Next": "ManualReview"
}
],
"Default": "ProcessDefault"
}
4. Wait - Delay execution
{
"Type": "Wait",
"Seconds": 60,
"Next": "NextState"
}
// Or wait until timestamp
{
"Type": "Wait",
"TimestampPath": "$.scheduledTime",
"Next": "NextState"
}
5. Parallel - Execute branches concurrently
{
"Type": "Parallel",
"Branches": [...],
"Next": "NextState"
}
6. Map - Iterate over array
{
"Type": "Map",
"ItemsPath": "$.items",
"Iterator": {...},
"Next": "NextState"
}
7. Succeed - Terminal success
{
"Type": "Succeed"
}
8. Fail - Terminal failure
{
"Type": "Fail",
"Error": "CustomError",
"Cause": "Error description"
}
5. How do you handle errors in Step Functions?
Error Handling Mechanisms:
1. Retry - Automatic retry with backoff
{
"Type": "Task",
"Resource": "arn:aws:lambda:...",
"Retry": [
{
"ErrorEquals": ["States.Timeout", "Lambda.ServiceException"],
"IntervalSeconds": 3,
"MaxAttempts": 3,
"BackoffRate": 2.0,
"MaxDelaySeconds": 60,
"JitterStrategy": "FULL"
},
{
"ErrorEquals": ["States.ALL"],
"IntervalSeconds": 1,
"MaxAttempts": 2
}
],
"Next": "NextState"
}
2. Catch - Handle errors gracefully
{
"Type": "Task",
"Resource": "arn:aws:lambda:...",
"Catch": [
{
"ErrorEquals": ["ValidationError"],
"ResultPath": "$.error",
"Next": "HandleValidationError"
},
{
"ErrorEquals": ["States.TaskFailed"],
"ResultPath": "$.error",
"Next": "HandleTaskFailure"
},
{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.error",
"Next": "CatchAllHandler"
}
],
"Next": "SuccessState"
}
Predefined Error Types:
âââ States.ALL: Matches any error
âââ States.Timeout: Task timeout
âââ States.TaskFailed: Task failure
âââ States.Permissions: Permission error
âââ States.ResultPathMatchFailure: ResultPath issue
âââ States.ParameterPathFailure: Parameter issue
âââ States.BranchFailed: Parallel branch failure
âââ States.NoChoiceMatched: No Choice match
âââ States.HeartbeatTimeout: Activity heartbeat timeout