-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
221 lines (198 loc) · 5.17 KB
/
serverless.yml
File metadata and controls
221 lines (198 loc) · 5.17 KB
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
service: astorgacollections-backend
package:
individually: true
plugins:
- serverless-bundle
- serverless-export-env
- serverless-stack-output
- serverless-dynamodb-local
- serverless-offline
custom:
stage: ${opt:stage, self:provider.stage}
userPoolName: astorgacollections-${self:custom.stage}-user-pool
studentProfilesTableName: astorgacollections-studprofiles-${self:custom.stage}
studentISATableName: astorgacollections-studisa-${self:custom.stage}
staffProfilesTableName: astorgacollections-staffprofiles-${self:custom.stage}
studentUserGroupName: student
staffUserGroupName: staff
staffAdminUserGroupName: staffadmin
adminUserGroupName: admin
output:
file: .stackoutput-${self:custom.stage}.json
dynamodb:
stages:
- ${self:provider.stage}
provider:
name: aws
stage: dev
runtime: nodejs10.x
region: eu-central-1
# These environment variables are made available to our functions under
# process.env
environment:
userPoolName: ${self:custom.userPoolName}
studentProfilesTableName: ${self:custom.studentProfilesTableName}
staffProfilesTableName: ${self:custom.staffProfilesTableName}
studentUserGroupName: ${self:custom.studentUserGroupName}
staffUserGroupName: ${self:custom.staffUserGroupName}
staffAdminUserGroupName: ${self:custom.staffAdminUserGroupName}
adminUserGroupName: ${self:custom.adminUserGroupName}
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:DescribeTable
- dynamodb:Scan
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "Fn::GetAtt": [ StudentProfilesDynamoDBTable, Arn ]
- "Fn::GetAtt": [ StaffProfilesDynamoDBTable, Arn ]
- Effect: "Allow"
Action:
- cognito-idp:AdminGetUser
- cognito-idp:ListUsers
- cognito-idp:ListUsersInGroup
- cognito-idp:AdminListGroupsForUser
- cognito-idp:AdminAddUserToGroup
- cognito-idp:AdminCreateUser
- cognito-idp:AdminDeleteUser
Resource:
- "Fn::GetAtt": [ CognitoUserPool, Arn ]
functions:
user:
handler: handler.user
events:
- http:
path: user
method: get
cors: true
authorizer: aws_iam
dashboard:
handler: handler.dashboard
events:
- http:
path: dashboard
method: get
cors: true
authorizer: aws_iam
listStaff:
handler: handler.listStaff
events:
- http:
path: staff
method: get
cors: true
authorizer: aws_iam
createStaff:
handler: handler.createStaff
events:
- http:
path: staff
method: post
cors: true
authorizer: aws_iam
getStaff:
handler: handler.getStaff
events:
- http:
path: staff/{staffId}
method: get
cors: true
authorizer: aws_iam
updateStaff:
handler: handler.updateStaff
events:
- http:
path: staff/{staffId}
method: put
cors: true
authorizer: aws_iam
deleteStaff:
handler: handler.deleteStaff
events:
- http:
path: staff/{staffId}
method: delete
cors: true
authorizer: aws_iam
listStudents:
handler: handler.listStudents
events:
- http:
path: student
method: get
cors: true
authorizer: aws_iam
createStudent:
handler: handler.createStudent
events:
- http:
path: student
method: post
cors: true
authorizer: aws_iam
getStudent:
handler: handler.getStudent
events:
- http:
path: student/{studentId}
method: get
cors: true
authorizer: aws_iam
updateStudent:
handler: handler.updateStudent
events:
- http:
path: student/{studentId}
method: put
cors: true
authorizer: aws_iam
deleteStudent:
handler: handler.deleteStudent
events:
- http:
path: student/{studentId}
method: delete
cors: true
authorizer: aws_iam
createStudentISA:
handler: handler.createStudentISA
events:
- http:
path: isa/{studentId}
method: post
cors: true
authorizer: aws_iam
getStudentISA:
handler: handler.getStudentISA
events:
- http:
path: isa/{studentId}
method: get
cors: true
authorizer: aws_iam
updateStudentISA:
handler: handler.updateStudentISA
events:
- http:
path: isa/{studentId}
method: put
cors: true
authorizer: aws_iam
deleteStudentISA:
handler: handler.deleteStudentISA
events:
- http:
path: isa/{studentId}
method: delete
cors: true
authorizer: aws_iam
resources:
- ${file(resources/api-gateway-errors.yml)}
- ${file(resources/dynamodb-table.yml)}
- ${file(resources/s3-bucket.yml)}
- ${file(resources/cognito-user-pool.yml)}
- ${file(resources/cognito-identity-pool.yml)}