-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
406 lines (400 loc) · 12.5 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
service: pennyboxapp
package:
exclude:
- node_modules/dynamodb-localhost/**
- node_modules/serverless-dynamodb-local/**
- node_modules/serverless-offline/**
- node_modules/aws-sdk
plugins:
- serverless-webpack
- serverless-mocha-plugin
- serverless-dynamodb-local
- serverless-offline # This order is important. should be below of dynamodb-local
# - serverless-dynamodb-autoscaling
- serverless-plugin-split-stacks
- serverless-domain-manager
- serverless-plugin-tracing
provider:
name: aws
runtime: nodejs6.10
stage: dev # prod
region: us-east-1
tracing: true # enable xray
environment:
SERVICE_NAME: ${self:service}
REGION: ${self:provider.region}
DB_PREFIX: ${self:custom.DB_PREFIX}
COGNITO_POOL_ID: ${self:custom.COGNITO_POOL_ID}
SEND_IN_BLUE: ${file(./cred.yml):${self:custom.stage}.SEND_IN_BLUE}
SNS_NOTI_TRIGGER_ARN: ${file(./config.yml):${self:custom.stage}.SNS_NOTI_TRIGGER_ARN}
SNS_PUSH_APN_ARN: ${file(./config.yml):${self:custom.stage}.SNS_PUSH_APN_ARN}
ERROR_LEVEL: ${file(./config.yml):${self:custom.stage}.ERROR_LEVEL}
AWS_XRAY_CONTEXT_MISSING: LOG_ERROR
iamRoleStatements:
- Effect: Allow
Action:
- "dynamodb:*"
Resource:
- "arn:aws:dynamodb:us-east-1:*"
- Effect: Allow
Action:
- "cognito-idp:*"
Resource:
- "arn:aws:cognito-idp:us-east-1:*"
- Effect: Allow
Action:
- "SNS:*"
Resource:
- "arn:aws:sns:us-east-1:*"
- Effect: Allow
Action:
- "xray:PutTraceSegments"
- "xray:PutTelemetryRecords"
Resource:
- "*"
custom:
stage: ${opt:stage, self:provider.stage}
DB_PREFIX: ${self:service}-${file(./config.yml):${self:custom.stage}.DB_PREFIX}
COGNITO_POOL_ID: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ID}
webpackIncludeModules: true
customDomain:
domainName: ${file(./config.yml):${self:custom.stage}.CUSTOM_DOMAIN_NAME}
basePath: 'v2'
stage: ${self:custom.stage}
createRoute53Record: true
dynamodb:
start:
port: 8000
inMemory: true
migrate: true
seed: true
seed:
domain:
sources:
- table: ${file(fixtures/migrations/family.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/family.json]
- table: ${file(fixtures/migrations/family-user.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/family-user.json]
- table: ${file(fixtures/migrations/job.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/job.json]
- table: ${file(fixtures/migrations/withdrawal.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/withdrawal.json]
- table: ${file(fixtures/migrations/transaction.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/transaction.json]
- table: ${file(fixtures/migrations/notification.yml):Properties.TableName}
sources: [./fixtures/offline-seeds/notification.json]
# serverless-mocha-plugin:
# preTestCommands:
# - bash ./test/support/startOffline.sh
# postTestCommands:
# - bash ./test/support/stopOffline.sh
# capacities:
# - table: ${self:custom.DB_PREFIX}-todos
# read:
# minimum: 5 # Minimum read capacity
# maximum: 1000 # Maximum read capacity
# usage: 0.75 # Targeted usage percentage
# write:
# minimum: 40 # Minimum write capacity
# maximum: 200 # Maximum write capacity
# usage: 0.5 # Targeted usage percentage
functions:
checkHealth:
handler: src/handlers/misc.health
tracing: false
events:
- http:
method: GET
path: health
cors: true
#authorizer: aws_iam
getMe:
handler: src/handlers/user.getMe
events:
- http:
method: GET
path: user/me
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
getFamily:
handler: src/handlers/family.get
events:
- http:
method: GET
path: family/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
createFamily:
handler: src/handlers/family.create
events:
- http:
method: POST
path: family
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
joinFamily:
handler: src/handlers/family.join
events:
- http:
method: POST
path: family/join
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
preSignup:
handler: src/handlers/signup.preSignup
# events:
# - cognitoUserPool:
# pool: PennyboxAppUsers-${self:custom.stage}
# trigger: PreSignUp
# timeout: 5
postConfirmation:
handler: src/handlers/signup.postConfirmation
# events:
# - cognitoUserPool:
# pool: PennyboxAppUsers-${self:custom.stage}
# trigger: PostConfirmation
getJob:
handler: src/handlers/job.get
events:
- http:
method: GET
path: job/{jobId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
createJob:
handler: src/handlers/job.create
events:
- http:
method: POST
path: job
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
updateJobStatus:
handler: src/handlers/job.updateStatus
events:
- http:
method: PUT
path: job/{jobId}/status
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
updateJobSummary:
handler: src/handlers/job.updateSummary
events:
- http:
method: PUT
path: job/{jobId}/summary
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listJobsByFamilyMember:
handler: src/handlers/job.listByFamilyMember
events:
- http:
method: POST
path: user/me/jobs/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
- http:
method: POST
path: user/{userId}/jobs/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listJobsByFamily:
handler: src/handlers/job.listByFamily
events:
- http:
method: POST
path: family/{familyId}/jobs
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
getWithdrawal:
handler: src/handlers/withdrawal.get
events:
- http:
method: GET
path: withdrawal/{withdrawalId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
createWithdrawal:
handler: src/handlers/withdrawal.create
events:
- http:
method: POST
path: withdrawal
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
updateWithdrawalStatus:
handler: src/handlers/withdrawal.updateStatus
events:
- http:
method: PUT
path: withdrawal/{withdrawalId}/status
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listWithdrawalsByFamilyMember:
handler: src/handlers/withdrawal.listByFamilyMember
events:
- http:
method: POST
path: user/me/withdrawals/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
- http:
method: POST
path: user/{userId}/withdrawals/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listWithdrawalsByFamily:
handler: src/handlers/withdrawal.listByFamily
events:
- http:
method: POST
path: family/{familyId}/withdrawals
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listTransactionsByFamilyMember:
handler: src/handlers/transaction.listByFamilyMember
events:
- http:
method: POST
path: user/me/transactions/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
- http:
method: POST
path: user/{userId}/transactions/{familyId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
listTransactionsByFamily:
handler: src/handlers/transaction.listByFamily
events:
- http:
method: POST
path: family/{familyId}/transactions
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
forgotUsername:
handler: src/handlers/remind.forgotUsername
events:
- http:
method: POST
path: remind/family_usernames
cors: true
#authorizer: aws_iam
forgotPincode:
handler: src/handlers/remind.forgotPincode
events:
- http:
method: POST
path: remind/forgot_pincode
cors: true
#authorizer: aws_iam
sendNotification:
handler: src/handlers/notification.send
events:
- sns: ${file(./config.yml):${self:custom.stage}.SNS_NOTI_TRIGGER_ARN}
listMyNotifications:
handler: src/handlers/notification.listMine
events:
- http:
method: POST
path: user/me/notifications
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
markSingleNotificationAsRead:
handler: src/handlers/notification.markOneAsRead
events:
- http:
method: PUT
path: notification/{notificationId}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
getUnreadNotificationsCount:
handler: src/handlers/notification.getUnreadCount
events:
- http:
method: GET
path: notification/unread
cors: true
addMyDeviceToken:
handler: src/handlers/user.addDeviceToken
events:
- http:
method: POST
path: user/me/tokens
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
removeMyDeviceToken:
handler: src/handlers/user.removeDeviceToken
events:
- http:
method: DELETE
path: user/me/tokens/{token}
cors: true
authorizer:
name: authorizer
arn: ${file(./config.yml):${self:custom.stage}.COGNITO_POOL_ARN}
# you can add CloudFormation resource templates here
# resources:
# Resources:
# NewResource:
# Type: AWS::S3::Bucket
# Properties:
# BucketName: my-new-bucket
# Outputs:
# NewOutput:
# Description: "Description for the output"
# Value: "Some output value"
resources:
Resources:
FamilyDynamoDBTable: ${file(fixtures/migrations/family.yml)}
FamilyUserDynamoDBTable: ${file(fixtures/migrations/family-user.yml)}
JobDynamoDBTable: ${file(fixtures/migrations/job.yml)}
WithdrawalDynamoDBTable: ${file(fixtures/migrations/withdrawal.yml)}
TransactionDynamoDBTable: ${file(fixtures/migrations/transaction.yml)}
NotificationDynamoDBTable: ${file(fixtures/migrations/notification.yml)}