-
Notifications
You must be signed in to change notification settings - Fork 4
/
serverless.yml
282 lines (254 loc) · 7.36 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
service: codex
provider:
name: aws
stage: ${opt:stage, env:NODE_ENV, "dev"}
runtime: nodejs12.x
environment: ${file(./config/${self:provider.stage}.yml)}
memorySize: 256
timeout: 10
region: us-east-1
plugins:
- serverless-pseudo-parameters
- serverless-iam-roles-per-function
- serverless-webpack
- serverless-scriptable-plugin
- serverless-apigw-binary
package:
individually: true
custom:
apigwBinary:
types:
- 'image/webp'
scriptHooks:
# before:package:createDeploymentArtifacts: npm run build
webpack:
webpackConfig: 'webpack.config.js'
includeModules:
forceExclude:
- aws-sdk
- chrome-aws-lambda
packager: 'npm'
layers:
curl:
path: layers/curl-settings
description: 'utility functions'
compatibleRuntimes:
- nodejs8.10
- nodejs10.x
- nodejs12.x
licenseInfo: MIT
canvas:
package:
artifact: layers/canvas-lib64-layer.zip
# TODO: move SNS access into read and write access
sqsAccess: &sqsAccess
Effect: Allow
Action:
- sqs:*
snsAccess: &snsAccess
Effect: Allow
Action:
- sns:*
Resource: arn:aws:sns:${opt:region, self:provider.region}:#{AWS::AccountId}:${self:provider.environment.AWS_SNS}
dynamodbWriteAccess: &dynamodbWriteAccess
Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource: arn:aws:dynamodb:${opt:region, self:provider.region}:#{AWS::AccountId}:table/${self:provider.environment.AWS_DYNAMODB_TABLE}
dynamodbReadAccess: &dynamodbReadAccess
Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:Scan
- dynamodb:Query
Resource: arn:aws:dynamodb:${opt:region, self:provider.region}:#{AWS::AccountId}:table/${self:provider.environment.AWS_DYNAMODB_TABLE}
s3Access: &s3Access
Effect: Allow
Action:
- s3:*
Resource:
- "arn:aws:s3:::${self:provider.environment.S3_SCREENSHOT_BUCKET}/*"
- "arn:aws:s3:::${self:provider.environment.S3_SCREENSHOT_BUCKET}"
snsFunctionTemplate: &snsFunctionTemplate
iamRoleStatements:
- *snsAccess
- *dynamodbWriteAccess
events:
- sns: arn:aws:sns:${opt:region, self:provider.region}:#{AWS::AccountId}:${self:provider.environment.AWS_SNS}
httpFunctionTemplate: &httpFunctionTemplate
iamRoleStatements:
- *snsAccess
- *dynamodbReadAccess
functions:
# --------------------------------- daily functions -------------------------------------
sns-color-detection:
<<: *snsFunctionTemplate
memorySize: 2048
timeout: 75
environment: ${file(./config/fn.http-color-detection.yml)}
handler: functions/daily/color-detection.handler
layers:
- arn:aws:lambda:us-east-1:332013964457:layer:chrome-aws-lambda:1
iamRoleStatements:
- *snsAccess
- *dynamodbWriteAccess
- *s3Access
sns-alexa-rank:
<<: *snsFunctionTemplate
timeout: 20
handler: functions/daily/alexa-ranking.handler
environment: ${file(./config/fn.alexa-ranking.yml)}
sns-technology-detection:
<<: *snsFunctionTemplate
environment: ${file(./config/fn.technology-detection.yml)}
handler: functions/daily/technology-detection.handler
memorySize: 2048
timeout: 75
layers:
- arn:aws:lambda:us-east-1:332013964457:layer:chrome-aws-lambda:1
sns-color-bar:
<<: *snsFunctionTemplate
environment: ${file(./config/fn.color-bar.yml)}
handler: functions/daily/color-bar.handler
timeout: 15
sns-html-stats:
<<: *snsFunctionTemplate
timeout: 20
handler: functions/daily/html-stats.handler
environment: ${file(./config/fn.html-stats.yml)}
sns-lighthouse:
<<: *snsFunctionTemplate
memorySize: 2048
timeout: 60
handler: functions/daily/lighthouse.handler
layers:
- arn:aws:lambda:us-east-1:332013964457:layer:chrome-aws-lambda:1
environment: ${file(./config/fn.lighthouse.yml)}
sns-css-stats:
<<: *snsFunctionTemplate
timeout: 50
memorySize: 1024
handler: functions/daily/css-stats.handler
sns-http-headers:
<<: *snsFunctionTemplate
handler: functions/daily/http-headers.handler
convert-images:
timeout: 60
memorySize: 2048
handler: functions/daily/convert-images.handler
environment: ${file(./config/fn.convert-images.yml)}
iamRoleStatements:
- *s3Access
# ---------------------------------------- HTTP Functions ---------------------------------------
http-color-detection:
environment: ${file(./config/fn.http-color-detection.yml)}
timeout: 60
memorySize: 1536
layers:
- arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:10
handler: functions/api/color-detection.handler
iamRoleStatements:
- *snsAccess
- *dynamodbReadAccess
- Effect: Allow
Action:
- s3:*
Resource:
- "arn:aws:s3:::webcodex-temporal/*"
- "arn:aws:s3:::webcodex-temporal"
events:
- http:
path: /try/color-detection/{domain}
method: GET
cors: true
http-color-bar:
timeout: 15
environment: ${file(./config/fn.color-bar.yml)}
handler: functions/api/color-bar.handler
events:
- http:
path: /try/color-bar/{domain}
method: GET
cors: true
http-technology-detection:
memorySize: 2048
timeout: 60
environment: ${file(./config/fn.technology-detection.yml)}
handler: functions/api/technology-detection.handler
layers:
- arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:10
events:
- http:
path: /try/technology-detection/{domain}
method: GET
cors: true
http-html-stats:
timeout: 20
handler: functions/api/html-stats.handler
layers:
- {Ref: CanvasLambdaLayer}
events:
- http:
path: /try/html-stats/{domain}
method: GET
cors: true
http-alexa-ranking:
handler: functions/api/alexa-ranking.handler
environment: ${file(./config/fn.alexa-ranking.yml)}
layers:
- {Ref: CanvasLambdaLayer}
events:
- http:
path: /try/alexa-ranking/{domain}
method: GET
cors: true
http-http-headers:
handler: functions/api/http-headers.handler
events:
- http:
path: /try/http-headers/{domain}
method: GET
cors: true
http-css-stats:
timeout: 50
memorySize: 1024
handler: functions/api/css-stats.handler
events:
- http:
path: /try/css-stats/{domain}
method: GET
cors: true
http-lighthouse:
memorySize: 1536
timeout: 60
layers:
- arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:10
handler: functions/api/lighthouse.handler
environment: ${file(./config/fn.lighthouse.yml)}
events:
- http:
path: /try/lighthouse/{domain}
method: GET
cors: true
http-latest-screenshot:
handler: functions/api/latest-screenshot.handler
environment: ${file(./config/fn.lighthouse.yml)}
iamRoleStatements:
- *snsAccess
- *dynamodbReadAccess
- *s3Access
events:
- http:
path: /try/latest-screenshot/{domain}
method: GET
cors: true
http-optimize-image:
handler: functions/api/optimize-image.handler
environment: ${file(./config/fn.http-optimize-image.yml)}
events:
- http:
path: /try/optimize-image
method: GET
cors: true