This repository has been archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserverless.yml
222 lines (217 loc) · 6.59 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
service: smoke-detector-aws
frameworkVersion: ">=1.1.0 <2.0.0"
plugins:
- serverless-aws-documentation
provider:
name: aws
runtime: python3.6
region: ${env:AWS_REGION, 'us-east-1'}
stage: ${env:AWS_STAGE, 'dev'}
environment:
BLACKLIST_TABLE: { "Ref": "DdbBlacklists" }
NOTIFICATIONS_TABLE: { "Ref": "DdbNotifications" }
ACCESSTOKENS_TABLE: { "Ref": "DdbAccessTokens" }
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- { "Fn::GetAtt": ["DdbBlacklists", "Arn"] }
- { "Fn::GetAtt": ["DdbNotifications", "Arn"] }
- { "Fn::GetAtt": ["DdbAccessTokens", "Arn"] }
functions:
authorize_user:
handler: authorizers/users.authorize
authorize_metasmoke:
handler: authorizers/users.authorize_metasmoke
create_auth_token:
handler: authorizers/create_token.create_token
events:
- http:
path: auth/create
method: post
cors: true
authorizer: ${self:custom.authorizer.metasmoke}
list_blacklists:
handler: blacklists/list_blacklists.list_blacklist_by_type
events:
- http:
path: blacklists/{id}
method: get
cors: true
create_blacklist:
handler: blacklists/create_blacklist.create_blacklist_item
events:
- http:
path: blacklists/{id}
method: post
cors: true
authorizer: ${self:custom.authorizer.users}
delete_blacklist:
handler: blacklists/delete_blacklist.delete_blacklist_item
events:
- http:
path: blacklists/{id}
method: delete
cors: true
authorizer: ${self:custom.authorizer.users}
blacklist_error:
handler: blacklists/blacklist_errors.invalid_path
events:
- http:
path: blacklists/
method: any
list_notifications:
handler: notifications/list_notifications.list_all_notifications
events:
- http:
path: notifications
method: get
cors: true
create_notification:
handler: notifications/create_notification.create_notification_item
events:
- http:
path: notifications
method: post
cors: true
authorizer: ${self:custom.authorizer.users}
delete_notification:
handler: notifications/delete_notification.delete_notification_item
events:
- http:
path: notifications
method: delete
cors: true
authorizer: ${self:custom.authorizer.users}
custom:
authorizer:
users:
name: authorize_user
type: TOKEN
identitySource: method.request.header.Authorization
identityValidationExpression: (.*)
resultTtlInSeconds: 30
metasmoke:
name: authorize_user
type: TOKEN
identitySource: method.request.header.Authorization
identityValidationExpression: (.*)
resultTtlInSeconds: 30
resources:
Resources:
DdbBlacklists:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "type"
AttributeType: "S"
- AttributeName: "text_pattern"
AttributeType: "S"
GlobalSecondaryIndexes:
- IndexName: "text_pattern-index"
KeySchema:
- AttributeName: "text_pattern"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
- IndexName: "type-index"
KeySchema:
- AttributeName: "type"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 1
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 1
TableName: ${self:service}-${opt:stage, self:provider.stage}-blacklists
DdbNotifications:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: "user_server_room_site"
AttributeType: "S"
- AttributeName: "user_id"
AttributeType: "N"
- AttributeName: "server"
AttributeType: "S"
- AttributeName: "room_id"
AttributeType: "N"
- AttributeName: "site"
AttributeType: "S"
GlobalSecondaryIndexes:
- IndexName: "user_id-index"
KeySchema:
- AttributeName: "user_id"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
- IndexName: "server-index"
KeySchema:
- AttributeName: "server"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
- IndexName: "room_id-index"
KeySchema:
- AttributeName: "room_id"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
- IndexName: "site-index"
KeySchema:
- AttributeName: "site"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
KeySchema:
- AttributeName: "user_server_room_site"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:service}-${opt:stage, self:provider.stage}-notifications
DdbAccessTokens:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: "token"
AttributeType: "S"
KeySchema:
- AttributeName: "token"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:service}-${opt:stage, self:provider.stage}-tokens