-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
283 lines (260 loc) · 8.7 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
service: ini-ride
frameworkVersion: '3'
configValidationMode: error
plugins:
- serverless-plugin-typescript
- serverless-offline
- serverless-export-env
- serverless-stack-output
useDotenv: true
custom:
accountId: 846727667520
allowedHeaders:
- Accept
- Content-Type
- Content-Length
- Authorization
- X-Amz-Date
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
- app_user_id
- app_user_name
serverless-offline:
ignoreJWTSignature: true
output:
handler: scripts/output.handler
file: env.toml
export-env:
filename: .env
overwrite: true
enableOffline: true
provider:
name: aws
runtime: nodejs14.x
region: eu-west-1
stage: dev
memorySize: 128
timeout: 5
endpointType: regional
logs:
restApi:
accessLogging: true
executionLogging: true
httpApi: true
environment:
DB_TABLE: ${env:DB_TABLE}
DB_TABLE_RIDES: ${env:DB_TABLE_RIDES}
DB_TABLE_LOCATION: ${env:DB_TABLE_LOCATION}
USER_POOL: ${env:USER_POOL}
USER_POOL_ID: ${env:USER_POOL_ID}
USER_POOL_ARN: arn:aws:cognito-idp:${self:provider.region}:${self:custom.accountId}:userpool/${env:USER_POOL_ID}
USER_POOL_URL: https://cognito-idp.${self:provider.region}.amazonaws.com/${env:USER_POOL_ID}
USER_POOL_CLIENT: ${self:service}-${opt:stage, self:provider.stage}
USER_POOL_CLIENT_ID: ${env:USER_POOL_CLIENT_ID}
USER_POOL_APPLICATION_CLIENT_ID: ${env:USER_POOL_APPLICATION_CLIENT_ID}
USER_POOL_APPLICATION_CLIENT_SECRET: ${env:USER_POOL_APPLICATION_CLIENT_SECRET}
REGION: ${self:provider.region}
USER_POOL_ROOT_USER: "vinoselv"
USER_POOL_ROOT_USER_PASSWORD: "p@ssw0rD"
LOG_LEVEL: "debug"
DEFAULT_FUNCTION_TIMEOUT: 10
HTTP_API_URL:
'Fn::ImportValue': '${self:service}-${opt:stage, self:provider.stage}-http-endpoint'
IOT_CORE_ENDPOINT: 'a12ucxj1zaaa1x-ats.iot.eu-west-1.amazonaws.com'
iam:
role:
name: ${self:service}-${opt:stage, self:provider.stage}-iam-role
statements:
- Effect: "Allow"
Action:
- iot:publish
Resource:
- arn:aws:iot:${self:provider.region}:${self:custom.accountId}:topic/*
- Effect: "Allow"
Action:
- cognito-identity:*
- cognito-sync:*
- cognito-idp:*
- iam:ListRoles,
- iam:ListOpenIdConnectProviders,
- sns:ListPlatformApplications
Resource:
- ${self:provider.environment.USER_POOL_ARN}
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:PutItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
- dynamodb:BatchGetItem
Resource:
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE}
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE}/index/*
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE_RIDES}
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE_RIDES}/index/*
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE_LOCATION}
- arn:aws:dynamodb:${self:provider.region}:${self:custom.accountId}:table/${env:DB_TABLE_LOCATION}/index/*
httpApi:
cors: true
authorizers:
serviceAuthorizer:
type: jwt
identitySource: $request.header.Authorization
issuerUrl: ${self:provider.environment.USER_POOL_URL}
audience:
- ${self:provider.environment.USER_POOL_CLIENT_ID}
- ${self:provider.environment.USER_POOL_APPLICATION_CLIENT_ID}
functions:
create-user:
handler: api/user/CreateUser.handler
description: POST /user
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /user
method: post
authorizer: serviceAuthorizer
authenticate-user:
handler: api/user/AuthenticateUser.handler
description: POST /user/authenticate
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /user/authenticate
method: post
authorizer: serviceAuthorizer
get-user:
handler: api/user/GetUser.handler
description: GET /user
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /user
method: get
authorizer: serviceAuthorizer
delete-user:
handler: api/user/DeleteUser.handler
description: DELETE /user/{user_id}
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /user/{user_id}
method: delete
authorizer: serviceAuthorizer
create-ride-offer:
handler: api/ride/CreateRideOffer.handler
description: POST /ride-offer
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /ride-offer
method: post
authorizer: serviceAuthorizer
create-ride-request:
handler: api/ride/CreateRideRequest.handler
description: POST /ride/{ride_id}/request
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /rides/{ride_id}/request
method: post
authorizer: serviceAuthorizer
get-rides:
handler: api/ride/GetRides.handler
description: GET /rides
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /rides
method: get
authorizer: serviceAuthorizer
get-ride:
handler: api/ride/GetRide.handler
description: GET /rides/{ride_id}
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /rides/{ride_id}
method: get
authorizer: serviceAuthorizer
delete-ride:
handler: api/ride/DeleteRide.handler
description: DELETE /ride/{ride_id}
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /rides/{ride_id}
method: delete
authorizer: serviceAuthorizer
search-rides:
handler: api/ride/SearchRides.handler
description: POST /search-rides
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /search-rides
method: post
authorizer: serviceAuthorizer
update-ride-status:
handler: api/ride/UpdateRideStatus.handler
description: POST /ride-status
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /ride-status
method: post
authorizer: serviceAuthorizer
create-car-request:
handler: api/car/CreateCar.handler
description: POST /car
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /car
method: post
authorizer: serviceAuthorizer
update-car-request:
handler: api/car/UpdateCar.handler
description: PATCH /car
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /car
method: patch
authorizer: serviceAuthorizer
get-car:
handler: api/car/GetCar.handler
description: GET /car
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /car
method: get
authorizer: serviceAuthorizer
delete-car:
handler: api/car/DeleteCar.handler
description: DELETE /car
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
events:
- httpApi:
path: /car
method: delete
authorizer: serviceAuthorizer
mqtt-bridge:
handler: api/mqtt/MqttBridge.handler
description: MQTT bridge to route events to another topic
timeout: ${self:provider.environment.DEFAULT_FUNCTION_TIMEOUT}
package:
patterns:
- '!package-lock.json'
resources:
Outputs:
HttpApiUrl:
Export:
Name: ${self:service}-${opt:stage, self:provider.stage}-http-endpoint