-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
181 lines (167 loc) · 5.21 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
service: step-function-secret-santa
frameworkVersion: '3'
custom:
allocationBucketName: 'secret-santa-allocations-${self:provider.stage}'
provider:
name: aws
region: ${opt:region, 'us-east-1'}
stage: ${opt:stage, 'dev'}
memorySize: 512
plugins:
- serverless-step-functions
- serverless-iam-roles-per-function
package:
individually: true
functions:
parse-participants:
handler: ParseParticipantsHandler::ParseParticipants.Handler::Handle
runtime: dotnet6
package:
artifact: src/parse-participants/bin/Release/net6.0/parse-participants.zip
validate-participants:
handler: src/validate-participants/handler.handle
runtime: nodejs16.x
package:
patterns:
- '!./**'
- ./src/validate-participants/handler.js
allocate:
handler: src/allocate/handler.handle
runtime: provided.al2
layers:
- 'arn:aws:lambda:us-east-1:428533468732:layer:santa-lang:3'
package:
patterns:
- '!./**'
- ./src/allocate/handler.santa
validate-allocations:
handler: com.secretsanta.Handler
runtime: java11
package:
artifact: src/validate-allocations/target/validate-allocations-dev.jar
store-allocations:
handler: src/store-allocations/bin/handler
runtime: go1.x
package:
patterns:
- '!./**'
- ./src/store-allocations/bin/handler
environment:
ALLOCATION_BUCKET: !Ref AllocationBucket
iamRoleStatements:
- Effect: 'Allow'
Action: 's3:PutObject'
Resource: 'arn:aws:s3:::${self:custom.allocationBucketName}/*'
notify-sms:
handler: handler.handle
runtime: ruby2.7
package:
artifact: src/notify-sms/notify-sms.zip
environment: ${file(./env.yml):notify-sms}
notify-email:
handler: handler.handle
runtime: python3.9
package:
artifact: src/notify-email/notify-email.zip
environment: ${file(./env.yml):notify-email}
stepFunctions:
validate: true
stateMachines:
secret-santa:
name: 'secret-santa-${self:provider.stage}'
events:
- http:
path: /
method: POST
request:
template: lambda_proxy
definition:
StartAt: 'Parse Participants'
States:
'Parse Participants':
Type: Task
Resource:
Fn::GetAtt: [parse-participants, Arn]
Next: 'Validate Participants'
'Validate Participants':
Type: Task
Resource:
Fn::GetAtt: [validate-participants, Arn]
Next: 'Allocate'
'Allocate':
Type: Task
Resource:
Fn::GetAtt: [allocate, Arn]
Next: 'Validate Allocations'
'Validate Allocations':
Type: Task
Resource:
Fn::GetAtt: [validate-allocations, Arn]
Catch:
- ErrorEquals: ['States.ALL']
ResultPath: '$.error'
Next: 'Allocate'
Next: 'Store Allocations'
'Store Allocations':
Type: Task
Resource:
Fn::GetAtt: [store-allocations, Arn]
Next: 'Notify Participants'
'Notify Participants':
Type: Parallel
End: true
Branches:
- StartAt: 'Notify Email'
States:
'Notify Email':
Type: Map
ItemsPath: '$.allocations'
End: true
Iterator:
StartAt: 'Should Email?'
States:
'Should Email?':
Type: Choice
Choices:
- Variable: '$.participant.email'
StringMatches: ''
Next: 'No Email'
Default: 'Email'
'Email':
Type: Task
End: true
Resource:
Fn::GetAtt: [notify-email, Arn]
'No Email':
Type: Pass
End: true
- StartAt: 'Notify SMS'
States:
'Notify SMS':
Type: Map
ItemsPath: '$.allocations'
End: true
Iterator:
StartAt: 'Should SMS?'
States:
'Should SMS?':
Type: Choice
Choices:
- Variable: '$.participant.number'
StringMatches: ''
Next: 'No SMS'
Default: 'SMS'
'SMS':
Type: Task
End: true
Resource:
Fn::GetAtt: [notify-sms, Arn]
'No SMS':
Type: Pass
End: true
resources:
Resources:
AllocationBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.allocationBucketName}