-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
80 lines (75 loc) · 2.01 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
org: aredotna
app: dossier-url
service: dossier-url
custom:
bucket: arena-dossier
bundle:
caching: false
packagerOptions:
scripts:
- rm -rf node_modules/sharp && npm install --arch=x64 --platform=linux --target=10.15.0 sharp
plugins:
- serverless-plugin-include-dependencies
- serverless-dotenv-plugin
provider:
name: aws
runtime: nodejs10.x
memorySize: 3008
timeout: 120
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource: "arn:aws:s3:::${self:custom.bucket}/*"
resources:
Resources:
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Comment: CloudFront caching for Dossier (${opt:stage, 'dev'})
DefaultCacheBehavior:
TargetOriginId: DossierOrigin
ViewerProtocolPolicy: "redirect-to-https"
DefaultTTL: 86400
ForwardedValues:
Headers:
- x-auth-token
QueryString: true
QueryStringCacheKeys:
- url
Enabled: true
Origins:
- Id: DossierOrigin
DomainName:
Fn::Join:
- "."
- - Ref: ApiGatewayRestApi
- execute-api.us-east-1.amazonaws.com
OriginPath: /${opt:stage, 'dev'}
CustomOriginConfig:
HTTPPort: 80
HTTPSPort: 443
OriginProtocolPolicy: https-only
functions:
URLScreenshot:
handler: screenshot.getURLScreenshot
timeout: 120
layers:
- arn:aws:lambda:us-east-1:583577227413:layer:ChromeAwsLambda:1
environment:
BUCKET: ${self:custom.bucket}
TOKEN: ${env:DOSSIER_TOKEN}
events:
- http:
path: screenshot
method: get
cors: true
URLMetadata:
handler: index.getURLMetadata
events:
- http:
path: metadata
method: get
cors: true