Skip to content

Instantly share code, notes, and snippets.

@rhosys-service-account
Last active November 21, 2020 10:35
Show Gist options
  • Save rhosys-service-account/43bd1f774be877766303db2d22101321 to your computer and use it in GitHub Desktop.
Save rhosys-service-account/43bd1f774be877766303db2d22101321 to your computer and use it in GitHub Desktop.
Step Function execution example including error handling
/** Example used to support creating custom domains with https://authress.io */
const stepFunctionResource = {
"Type": "AWS::StepFunctions::StateMachine",
"Properties": {
"StateMachineName": {
"Fn::Sub": "${AWS::StackName}-CustomDomain"
},
"LoggingConfiguration": {
"Destinations": [{
"CloudWatchLogsLogGroup": {
"LogGroupArn": {
"Fn::Sub": "${CloudWatchLambdaLogGroup.Arn}"
}
}
}],
"IncludeExecutionData": true,
"Level": "FATAL"
},
"DefinitionString": {
"Fn::Sub": JSON.stringify({
"StartAt": "Start",
"States": {
"Start": {
"Type": "Task",
"Resource": "${ProductionAlias}",
"Parameters": {
"context.$": "$$"
},
"ResultPath": "$.executionResult",
"Next": "Verify",
"Retry": [{
"ErrorEquals": ["States.ALL"],
"IntervalSeconds": 10,
"MaxAttempts": 18,
"BackoffRate": 2
}]
},
"Verify": {
"Type": "Task",
"Resource": "${ProductionAlias}",
"Parameters": {
"context.$": "$$"
},
"ResultPath": "$.executionResult",
"End": true,
"Retry": [{
"ErrorEquals": ["States.ALL"],
"IntervalSeconds": 10,
"MaxAttempts": 18,
"BackoffRate": 2
}]
}
}
})
},
"RoleArn": { "Fn::GetAtt": ["StepFunctionRole", "Arn"] }
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment