Created
September 30, 2022 20:40
-
-
Save beabetterdevv/e93f2e0962948e5b7f196198ffa529db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Comment": "A description of my state machine", | |
"StartAt": "Add Order Entry", | |
"States": { | |
"Add Order Entry": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::dynamodb:putItem", | |
"Parameters": { | |
"TableName": "CustomerOrdersTable", | |
"Item": { | |
"customerId": { | |
"S.$": "$.customerId" | |
}, | |
"orderId": { | |
"S.$": "$.orderId" | |
} | |
} | |
}, | |
"ResultSelector": { | |
"statusCode.$": "$.SdkHttpMetadata.HttpStatusCode" | |
}, | |
"ResultPath": "$.result", | |
"Next": "Choice" | |
}, | |
"Choice": { | |
"Type": "Choice", | |
"Choices": [ | |
{ | |
"Variable": "$.result.statusCode", | |
"NumericEquals": 200, | |
"Next": "Call Credit Card Service To Charge Customer" | |
} | |
], | |
"Default": "Fail" | |
}, | |
"Call Credit Card Service To Charge Customer": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::lambda:invoke", | |
"Parameters": { | |
"Payload.$": "$", | |
"FunctionName": "arn:aws:lambda:us-east-1:755314965794:function:Test:$LATEST" | |
}, | |
"Retry": [ | |
{ | |
"ErrorEquals": [ | |
"Lambda.ServiceException", | |
"Lambda.AWSLambdaException", | |
"Lambda.SdkClientException" | |
], | |
"IntervalSeconds": 2, | |
"MaxAttempts": 6, | |
"BackoffRate": 2 | |
} | |
], | |
"Next": "Success", | |
"Catch": [ | |
{ | |
"ErrorEquals": [ | |
"States.ALL" | |
], | |
"Next": "Fallback - Delete failed order", | |
"ResultPath": "$.result" | |
} | |
], | |
"ResultPath": "$.result" | |
}, | |
"Fallback - Delete failed order": { | |
"Type": "Task", | |
"Resource": "arn:aws:states:::dynamodb:deleteItem", | |
"Parameters": { | |
"TableName": "CustomerOrdersTable", | |
"Key": { | |
"customerId": { | |
"S.$": "$.customerId" | |
}, | |
"orderId": { | |
"S.$": "$.orderId" | |
} | |
} | |
}, | |
"Next": "Fail" | |
}, | |
"Success": { | |
"Type": "Succeed" | |
}, | |
"Fail": { | |
"Type": "Fail" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment