-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
239 lines (217 loc) · 6.62 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
service: backend
plugins:
- serverless-plugin-include-dependencies
- serverless-offline
provider:
name: aws
runtime: nodejs10.x
deploymentBucket:
name: ${file(./config.json):S3_bucketName}
deploymentPrefix: bicibici
environment:
TABLE_BIKES: ${file(./config.json):DB_Bikes}
TABLE_PLANS: ${file(./config.json):DB_Plans}
TABLE_STATIONS: ${file(./config.json):DB_Stations}
TABLE_USERS: ${file(./config.json):DB_User}
TABLE_REPORT: ${file(./config.json):DB_Report}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- {"Fn::GetAtt": ["BikeDynamoDBTable", "Arn"],}
- {"Fn::GetAtt": ["PlansDynamoDBTable", "Arn"],}
- {"Fn::GetAtt": ["StationsDynamoDBTable", "Arn"],}
- {"Fn::GetAtt": ["UsersDynamoDBTable", "Arn"],}
- {"Fn::GetAtt": ["ReportDynamoDBTable", "Arn"],}
functions:
verificar_movimiento_bicicleta:
handler: bicycleFunctions/verificar_movimiento.verificar_movimiento
events:
- iot:
name: ${file(./config.json):IoT_Name}
sql: ${file(./config.json):IoT_topic}
description: ${file(./config.json):IoT_Description}
enabled: true
sqlVersion: ${file(./config.json):IoT_Version}
- http:
path: verificar_movimiento
method: ANY
enviar_mensaje_emergencia:
handler: bicycleFunctions/mensaje_emergencia.mensaje_emergencia
events:
- iot:
name: ${file(./config.json):IoT_Emergency}
sql: ${file(./config.json):IoT_topic}
description: ${file(./config.json):IoT_Description}
enabled: true
sqlVersion: ${file(./config.json):IoT_Version}
- http:
path: mensaje_emergencia
method: ANY
obtener_planes_usuarios:
handler: userFunctions/obtener_planes.obtener_planes
events:
- http:
path: planes
method: ANY
obtener_usuario:
handler: userFunctions/obtener_usuario.obtener_usuario
events:
- http:
path: usuario
method: ANY
revisar_planes_usuarios:
handler: cloudWatchFunctions/revisar_planes.revisar_planes
events:
- schedule:
rate: rate(10 minutes)
enabled: false
- http:
path: revisar_planes
method: ANY
obtener_informacion_estaciones:
handler: userFunctions/informacion_estaciones.informacion_estaciones
events:
- http:
path: estacion
method: ANY
obtener_estacionamientos_cercanos:
handler: userFunctions/estacionamientos_cercanos.estacionamientos_cercanos
events:
- http:
path: estaciones
method: ANY
desbloquear_bicicleta:
handler: userFunctions/desbloquear_bicicleta.desbloquear_bicicleta
events:
- http:
path: desbloquearBicicleta
method: ANY
finalizar_viaje:
handler: userFunctions/finalizar_viaje.finalizar_viaje
events:
- http:
path: finalizar_viaje
method: ANY
registrar_pago:
handler: userFunctions/registrar_pago.registrar_pago
events:
- http:
path: registrar_pago
method: ANY
registrar_contacto_emergencia:
handler: userFunctions/registrar_emergencia.registrar_emergencia
events:
- http:
path: registrar_emergencia
method: ANY
calcular_datos:
handler: userFunctions/calcular_datos.calcular_datos
events:
- http:
path: calcular_datos
method: ANY
reportar_bicicleta:
handler: userFunctions/reportar_bicicleta.reportar_bicicleta
events:
- http:
path: reportar_bicicleta
method: ANY
registrar_usuario:
handler: userFunctions/registrar_usuario.registrar_usuario
events:
#need manual configuration
#ref forr names https://docs.aws.amazon.com/es_es/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
#- cognitoUserPool:
#pool: ${file(./config.json):Cognito_pool}
#trigger: PostConfirmation
#existing: true
#https://medium.com/@Da_vidgf/using-cognito-for-users-management-in-your-serverless-application-1695fec9e225
resources:
Resources:
BikeDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: uuidBike
AttributeType: S
KeySchema:
-
AttributeName: uuidBike
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_BIKES}
PlansDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: uuidPlan
AttributeType: S
KeySchema:
-
AttributeName: uuidPlan
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_PLANS}
StationsDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: uuidStation
AttributeType: S
KeySchema:
-
AttributeName: uuidStation
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_STATIONS}
UsersDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: uuidUser
AttributeType: S
KeySchema:
-
AttributeName: uuidUser
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_USERS}
ReportDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: uuidReport
AttributeType: S
KeySchema:
-
AttributeName: uuidReport
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_REPORT}