@@ -124,141 +124,16 @@ Resources:
124124 Properties :
125125 StateMachineName : !Ref "AWS::StackName"
126126 RoleArn : !GetAtt StepFunctionsServiceRole.Arn
127- DefinitionString : !Sub |-
127+ DefinitionString : |-
128128 {
129129 "Comment": "re:Invent 2018 Builder Session - Managing Long Lived Transactions with AWS Step Functions State Machine",
130130 "StartAt": "ProcessOrder",
131131 "TimeoutSeconds": 15,
132132 "States": {
133133 "ProcessOrder": {
134134 "Comment": "First transaction to save the order and set the order status to new",
135- "Type": "Task",
136- "Resource": "${NewOrderFunction.Arn}",
137- "TimeoutSeconds": 10,
138- "Catch": [{
139- "ErrorEquals": ["ErrProcessOrder"],
140- "ResultPath": "$.error",
141- "Next": "UpdateOrderStatus"
142- }],
143- "Next": "ProcessPayment"
144- },
145- "ProcessPayment": {
146- "Comment": "Task processes the order payment",
147- "Type": "Task",
148- "Resource": "${ProcessPaymentFunction.Arn}",
149- "TimeoutSeconds": 10,
150- "Catch": [{
151- "ErrorEquals": ["ErrProcessPayment"],
152- "ResultPath": "$.error",
153- "Next": "ProcessRefund"
154- }],
155- "Next": "ReserveInventory"
156- },
157- "ReserveInventory": {
158- "Comment": "Task to reserve order items in inventory",
159- "Type": "Task",
160- "Resource": "${ReserveInventoryFunction.Arn}",
161- "TimeoutSeconds": 10,
162- "Catch": [{
163- "ErrorEquals": ["ErrReserveInventory"],
164- "ResultPath": "$.error",
165- "Next": "ReleaseInventory"
166- }],
167- "Next": "sns:NotifySuccess"
168- },
169- "sns:NotifySuccess": {
170- "Type": "Task",
171- "Resource": "arn:aws:states:::sns:publish",
172- "Parameters": {
173- "Message.$": "$.order_id",
174- "TopicArn": "${SagaTopic}"
175- },
176- "ResultPath": "$.notification",
177- "Next": "OrderSucceeded"
178- },
179- "OrderSucceeded": {
180- "Type": "Succeed"
181- },
182- "ReleaseInventory": {
183- "Comment": "Task to release order items back to inventory",
184- "Type": "Task",
185- "Resource": "${ReleaseInventoryFunction.Arn}",
186- "TimeoutSeconds": 10,
187- "Retry": [{
188- "ErrorEquals": ["States.ALL"],
189- "IntervalSeconds": 1,
190- "MaxAttempts": 2,
191- "BackoffRate": 2.0
192- }],
193- "Catch": [{
194- "ErrorEquals": ["ErrReleaseInventory"],
195- "ResultPath": "$.error",
196- "Next": "sns:NotifyReleaseInventoryFail"
197- }],
198- "Next": "ProcessRefund"
199- },
200- "sns:NotifyReleaseInventoryFail": {
201- "Type": "Task",
202- "Resource": "arn:aws:states:::sns:publish",
203- "Parameters": {
204- "Message.$": "$.order_id",
205- "TopicArn": "${SagaTopic}"
206- },
207- "ResultPath": "$.notification",
208- "Next": "OrderFailed"
209- },
210- "ProcessRefund": {
211- "Comment": "Task to process order refund",
212- "Type": "Task",
213- "Resource": "${ProcessRefundFunction.Arn}",
214- "TimeoutSeconds": 10,
215- "Retry": [{
216- "ErrorEquals": ["States.TaskFailed"],
217- "IntervalSeconds": 1,
218- "MaxAttempts": 2,
219- "BackoffRate": 2.0
220- }],
221- "Catch": [{
222- "ErrorEquals": ["ErrProcessRefund"],
223- "ResultPath": "$.error",
224- "Next": "sns:NotifyProcessRefundFail"
225- }],
226- "Next": "UpdateOrderStatus"
227- },
228- "sns:NotifyProcessRefundFail": {
229- "Type": "Task",
230- "Resource": "arn:aws:states:::sns:publish",
231- "Parameters": {
232- "Message.$": "$.order_id",
233- "TopicArn": "${SagaTopic}"
234- },
235- "ResultPath": "$.notification",
236- "Next": "OrderFailed"
237- },
238- "UpdateOrderStatus": {
239- "Comment": "Task sets the order status to Pending.",
240- "Type": "Task",
241- "Resource": "${UpdateOrderFunction.Arn}",
242- "TimeoutSeconds": 10,
243- "Catch": [{
244- "ErrorEquals": ["ErrUpdateOrderStatus"],
245- "ResultPath": "$.error",
246- "Next": "sns:NotifyUpdateOrderFail"
247- }],
248- "Next": "sns:NotifyUpdateOrderFail"
249- },
250- "sns:NotifyUpdateOrderFail": {
251- "Type": "Task",
252- "Resource": "arn:aws:states:::sns:publish",
253- "Parameters": {
254- "Message.$": "$.order_id",
255- "TopicArn": "${SagaTopic}"
256- },
257- "ResultPath": "$.notification",
258- "Next": "OrderFailed"
259- },
260- "OrderFailed": {
261- "Type": "Fail"
135+ "Type": "Pass",
136+ "End": true
262137 }
263138 }
264139 }
0 commit comments