Slide 56
Slide 56 text
57
Advanced orchestration with Step Functions
{
"StartAt": "SimpleInvocation",
"States": {
"SimpleInvocation": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:HelloFunction",
"Next": "Choose1or2"
},
"Choose1or2": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.foo",
"NumericEquals": 1,
"Next": "Lambda1"
},
{
"Variable": "$.foo",
"NumericEquals": 2,
"Next": "ParallelInvocation"
}
],
"Default": "Unmatched"
},
"Lambda1": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:Lambda1",
"Next": "SuccessOrFailure"
},
"SuccessOrFailure": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.status",
"StringEquals": "SUCCESS",
"Next": "SendNotification"
},
{
"Variable": "$.status",
"StringEquals": "FAILURE",
"Next": "QueueError"
}
],
"Default": "Unmatched"
},
"SendNotification": {
"Type": "Succeed"
},
"QueueError": {
"Type": "Fail"
},
"ParallelInvocation": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "SendApprovalRequest",
"States": {
"SendApprovalRequest": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke.waitForTaskToken",
"Parameters": {
"FunctionName": "sendMailForApprovalFunction",
"Payload": {
"step.$": "$$.State.Name",
"model.$": "$.data",
"token.$": "$$.Task.Token"
}
},
"ResultPath": "$.output",
"Next": "Approved",
"Catch": [
{
"ErrorEquals": [ "rejected" ],
"ResultPath": "$.reason",
"Next": "Rejected"
}
]
},
"Approved": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:Lambda1",
"End": true
},
"Rejected": {
"Type": "Fail"
}
}
},
{
"StartAt": "Loop",
"States": {
"Loop": {
"Type": "Map",
"ItemsPath": "$.loopItems",
"Iterator": {
"StartAt": "LoopLambda",
"States": {
"LoopLambda": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:LoopFunction",
"End": true
}
}
},
"End": true
}
}
}
],
"End": true
},
"Unmatched": {
"Type": "Fail",
"Error": "DefaultStateError",
"Cause": "No Matches!"
}
}
}