-
Notifications
You must be signed in to change notification settings - Fork 22
/
serverless.yml
113 lines (106 loc) · 2.94 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
service: chromda
custom:
s3Bucket: chromda-files
snsTopic: chromda
provider:
name: aws
region: ${opt:region, 'us-east-1'}
versionFunctions: false
layers:
# Google Chrome for AWS Lambda as a layer
# Make sure you use the latest version depending on the region
# https://github.com/shelfio/chrome-aws-lambda-layer
- arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:10
# dependencies layer
- { Ref: ChromdaLambdaLayer }
runtime: nodejs12.x
memorySize: 2048
timeout: 30
tracing:
lambda: true
# See the API Gateway event below for additional details on api keys
# apiKeys:
# - key1
functions:
captureScreenshot:
handler: src/captureScreenshot.handler
description: Captures a screenshot of a webpage.
iamRoleStatements:
- Effect: Allow
Action:
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource: "*"
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
# If you plan to support multiple buckets via request parameter,
# add all possible buckets here
Resource: arn:aws:s3:::${self:custom.s3Bucket}/*
environment:
S3_REGION: ${self:provider.region}
S3_BUCKET: ${self:custom.s3Bucket}
# Optional vars
CHROMIUM_ARGS: "[]"
TIMEOUT: "30000"
IGNORE_HTTPS_ERRORS: "false"
VIEWPORT_WIDTH: "1920"
VIEWPORT_HEIGHT: "1200"
DEVICE_SCALE_FACTOR: "1"
IS_MOBILE: "false"
IS_LANDSCAPE: "false"
events:
# SNS Event
- sns:
arn: !Ref chromdaTopic
topicName: ${self:custom.snsTopic}
# API Gateway Events
# - http:
# path: capture
# method: post
# Uncomment the provider api key section above as well as the line
# below to enable private endpoint support
# private: true
# TODO: add SQS event
# TODO: add Scheduled event
layers:
chromda:
package:
# This file will be created during `npm run deploy`
artifact: layer/export/layer.zip
package:
exclude:
- layer/**
- node_modules/**
- package.json
- yarn.lock
resources:
Resources:
# Bucket where the screenshots are stored
chromdaBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
Properties:
BucketName: ${self:custom.s3Bucket}
AccessControl: Private
# Change this if you don't want public read access
chromdaBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:GetObject
Principal: "*"
Resource: arn:aws:s3:::${self:custom.s3Bucket}/*
Bucket:
Ref: chromdaBucket
chromdaTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:custom.snsTopic}
plugins:
- serverless-webpack
- serverless-iam-roles-per-function