-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
157 lines (152 loc) · 5.27 KB
/
serverless.yml
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
service: order-service
package:
individually: true
provider:
name: aws
runtime: nodejs12.x
region: ap-south-1
logRetentionInDays: ${self:custom.logRetentionInDays.${self:custom.stage}}
iamRoleStatements:
- Effect: Allow
Action:
- states:StartSyncExecution
Resource: "arn:aws:states:${opt:region, self:provider.region}:123456789:stateMachine:${self:provider.environment.stepfunction}"
plugins:
- serverless-bundle
- serverless-offline
- serverless-dotenv-plugin
- serverless-step-functions
- serverless-step-functions-offline
- serverless-pseudo-parameters
custom:
stage: ${opt:stage, self:provider.stage}
serverless-offline:
httpPort: 4000
lambdaPort: 4001
stepFunctionsOffline:
stepfunctionLamb: createshipment
SecondLambda: SecondLambda
createInternationalShipment: createInternationalShipment
verifyGenerationId: verifyGenerationId
generateDelhiveryLabel: generateDelhiveryLabel
razorpaycapture: razorpaycapture
zohosalesorderapproval: zohosalesorderapproval
logRetentionInDays:
prod: 30
dev: 7
functions:
SecondLambda:
description: Test Function
handler: controllers/secondlambda.secondlambdamethod
memorySize: 256
timeout: 30
ThirdLambda:
description: Test Function
handler: controllers/thirdlambda.thirdlambdamethod
memorySize: 256
timeout: 30
stepFunctions:
validate: true
stateMachines:
processOrderFlow:
type: EXPRESS
loggingConfig:
level: ALL
includeExecutionData: true
destinations:
- Fn::GetAtt: [StepFunctionLogGroup, Arn]
name: processOrderFlow-${opt:stage}
events:
- http:
path: /order
method: post
cors: true
action: StartSyncExecution
request:
name: ProcessOrderModel
description: "Validation model of the requestI"
schema:
application/json: ${file(./schema/fullfillment.json)} # define the valid JSON Schema for a content-type
passThrough: NEVER
template:
application/json: |
{
"input": "{ \"body\": $util.escapeJavaScript($input.json('$')), \"user\": \"$context.authorizer.claims.name\" }",
"stateMachineArn":"arn:aws:states:#{AWS::Region}:#{AWS::AccountId}:stateMachine:processOrderFlow-${opt:stage}"
}
definition:
Comment: "Step Function to create shipment,capture payment and invoice creation in zoho"
StartAt: Parallel
States:
Parallel:
Type: Parallel
End: true
Branches:
- StartAt: FirstStep
States:
FirstStep:
Type: Choice
Choices:
- Not:
Variable: "$.body.customerDetails.country"
StringEquals: "IN"
Next: ThirdLambda
- Variable: "$.body.customerDetails.country"
StringEquals: "IN"
Next: SecondLambda
Default: DefaultState
SecondLambda:
Type: Task
Resource:
Fn::GetAtt: [SecondLambda, Arn]
ResultPath: "$.shippingStatus"
Retry:
- ErrorEquals:
- Lambda.ServiceException
IntervalSeconds: 1
MaxAttempts: 2
BackoffRate: 2
- ErrorEquals:
- Lambda.AWSLambdaException
IntervalSeconds: 30
MaxAttempts: 2
BackoffRate: 2
End: true
ThirdLambda:
Type: Task
Resource:
Fn::GetAtt: [createInternationalShipment, Arn]
ResultPath: "$.shippingStatus"
Retry:
- ErrorEquals:
- Lambda.ServiceException
IntervalSeconds: 1
MaxAttempts: 2
BackoffRate: 2
- ErrorEquals:
- Lambda.AWSLambdaException
IntervalSeconds: 30
MaxAttempts: 2
BackoffRate: 2
End: true
DefaultState:
Type: Fail
Cause: "No Matches!"
Catch:
- ErrorEquals: ["States.ALL"]
Next: NotifySNS
NotifySNS:
Type: Task
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn: arn:aws:sns:${opt:region, self:provider.region}:123456789:${opt:stage, self:provider.stage}-ekatva-order-fullfillment
Message:
Input: "Failure in Step Function"
End: true
resources:
Resources:
StepFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/vendedlogs/states/processOrderFlow-logs-${self:custom.stage}
RetentionInDays: 7