Setting the file. One moment. Human In The Loop With Timeout Escalation Asl · AWS Step Functions · aws/agent-toolkit-for-aws · Skills Docs70
Creating Amazon Aurora Db Cluster With Instances
93
Routing Traffic With Route53 And CloudFront
Resilience Program Design
116.4
Migrating From Jsonpath To Jsonata
(opens in a new tab)
assets/human-in-the-loop-with-timeout-escalation.asl.json
JSON·111 lines·3 KB
"MessageBody"
:
"{% $string({'taskToken': $states.context.Task.Token, 'orderId': $states.input.orderId, 'approver': $states.input.primaryApprover}) %}"
11 },
12 "TimeoutSeconds": 86400,
13 "Assign": {
14 "orderId": "{% $states.input.orderId %}",
15 "approvalResult": "{% $states.result %}"
16 },
17 "Catch": [
18 {
19 "ErrorEquals": [
20 "States.Timeout"
21 ],
22 "Assign": {
23 "orderId": "{% $states.input.orderId %}",
24 "managerApprover": "{% $states.input.managerApprover %}",
25 "escalationReason": "Primary approver did not respond within 24 hours"
26 },
27 "Next": "EscalateToManager"
28 },
29 {
30 "ErrorEquals": [
31 "States.ALL"
32 ],
33 "Assign": {
34 "approvalError": "{% $states.errorOutput %}"
35 },
36 "Next": "ApprovalFailed"
37 }
38 ],
39 "Next": "EvaluateApproval"
40 },
41 "EscalateToManager": {
42 "Type": "Task",
43 "Resource": "arn:aws:states:::sns:publish",
44 "Arguments": {
45 "TopicArn": "arn:aws:sns:us-east-1:123456789012:EscalationNotifications",
46 "Subject": "Approval Escalation",
47 "Message": "{% 'Order ' & $orderId & ' requires manager approval. ' & $escalationReason %}"
48 },
49 "Next": "WaitForManagerApproval"
50 },
51 "WaitForManagerApproval": {
52 "Type": "Task",
53 "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
54 "Arguments": {
55 "QueueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/ApprovalQueue",
56 "MessageBody": "{% $string({'taskToken': $states.context.Task.Token, 'orderId': $orderId, 'approver': $managerApprover, 'escalated': true}) %}"
57 },
58 "TimeoutSeconds": 43200,
59 "Assign": {
60 "approvalResult": "{% $states.result %}"
61 },
62 "Catch": [
63 {
64 "ErrorEquals": [
65 "States.Timeout"
66 ],
67 "Assign": {
68 "approvalResult": {
69 "decision": "rejected",
70 "reason": "No response from manager within 12 hours; auto-rejected"
71 }
72 },
73 "Next": "EvaluateApproval"
74 },
75 {
76 "ErrorEquals": [
77 "States.ALL"
78 ],
79 "Assign": {
80 "approvalError": "{% $states.errorOutput %}"
81 },
82 "Next": "ApprovalFailed"
83 }
84 ],
85 "Next": "EvaluateApproval"
86 },
87 "EvaluateApproval": {
88 "Type": "Choice",
89 "Choices": [
90 {
91 "Condition": "{% $approvalResult.decision = 'approved' %}",
92 "Next": "ProcessApprovedOrder"
93 }
94 ],
95 "Default": "OrderRejected"
96 },
97 "ProcessApprovedOrder": {
98 "Type": "Succeed"
99 },
100 "OrderRejected": {
101 "Type": "Fail",
102 "Error": "OrderRejected",
103 "Cause": "{% $exists($approvalResult.reason) ? $approvalResult.reason : 'Approval denied' %}"
104 },
105 "ApprovalFailed": {
106 "Type": "Fail",
107 "Error": "ApprovalFailed",
108 "Cause": "{% $exists($approvalError.Cause) ? $approvalError.Cause : 'Approval process encountered an error' %}"
109 }
110 }
111}