-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws_statemachine_code.json
181 lines (181 loc) · 5.98 KB
/
aws_statemachine_code.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{
"Comment": "A description of my state machine",
"StartAt": "Agent1: Stock Search Agent",
"States": {
"Agent1: Stock Search Agent": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:ap-southeast-2:686255953271:function:z_ec_lambda_agent_1:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 1,
"MaxAttempts": 3,
"BackoffRate": 2
}
],
"Next": "Map"
},
"Map": {
"Type": "Map",
"ItemsPath": "$.response",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "INLINE"
},
"StartAt": "Pass",
"States": {
"Pass": {
"Parameters": {
"response.$": "States.Array($)"
},
"ResultPath": "$",
"Type": "Pass",
"Next": "Agent 2: Data Fetching Agent"
},
"Agent 2: Data Fetching Agent": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:ap-southeast-2:686255953271:function:z_ec_lambda_agent_2:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 1,
"MaxAttempts": 3,
"BackoffRate": 2
}
],
"Next": "Agent 3: Data Saving Agent"
},
"Agent 3: Data Saving Agent": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:ap-southeast-2:686255953271:function:z_ec_lambda_agent_3:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 1,
"MaxAttempts": 3,
"BackoffRate": 2
}
],
"End": true
}
}
},
"Next": "Agent 4: Data Analysis Agent"
},
"Agent 4: Data Analysis Agent": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:ap-southeast-2:686255953271:function:z_ec_lambda_agent_4:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 1,
"MaxAttempts": 3,
"BackoffRate": 2
}
],
"Next": "Parallel"
},
"Parallel": {
"Type": "Parallel",
"End": true,
"Branches": [
{
"StartAt": "Notification Queue",
"States": {
"Notification Queue": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage",
"Parameters": {
"MessageBody.$": "$",
"MessageGroupId": "defaultGroup",
"MessageDeduplicationId.$": "States.UUID()",
"QueueUrl": "https://sqs.ap-southeast-2.amazonaws.com/686255953271/z_ec_report.fifo"
},
"ResultPath": "$.sqsOutput",
"Next": "Mail Notification"
},
"Mail Notification": {
"Type": "Task",
"Parameters": {
"Destination": {
"ToAddresses": [
]
},
"Content": {
"Raw": {
"Data.$": "States.Format('Content-Type: multipart/related; boundary=\"boundary\"\r\nMIME-Version: 1.0\r\nSubject: {}\r\nFrom: [email protected]\r\nTo: [email protected]\r\n\r\n--boundary\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\n<html><body><h1>Hello {}</h1><p>Here is the image:</p><img src=\"cid:image1\" alt=\"Base64 Image\" /></body></html>\r\n\r\n--boundary\r\nContent-Type: image/png; name=\"image.png\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: inline; filename=\"image.png\"\r\nContent-ID: <image1>\r\n\r\n{}\r\n--boundary--', $.best_performer, $.best_performer, $.viz)"
}
},
"FromEmailAddress": "[email protected]"
},
"Resource": "arn:aws:states:::aws-sdk:sesv2:sendEmail",
"End": true
}
}
},
{
"StartAt": "Store Reports",
"States": {
"Store Reports": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "z_ec_ddb",
"Item": {
"report": {
"S.$": "States.UUID()"
},
"data": {
"S.$": "States.JsonToString($)"
}
}
},
"End": true
}
}
}
]
}
}
}