-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
127 lines (117 loc) · 3.18 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
service: serverless-event-collector
frameworkVersion: '2'
plugins:
- serverless-python-requirements
provider:
name: aws
region: us-east-1
runtime: python3.8
lambdaHashingVersion: 20201221
iam:
role:
managedPolicies:
# Let lambdas write to CloudWatch
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
statements:
- Effect: "Allow"
Action:
- apigateway:GET
- firehose:PutRecord
- "s3:*"
- "dynamodb:*"
Resource: "*"
apiGateway:
apiKeySourceType: AUTHORIZER
environment:
ENVIRONMENT: ${opt:stage}
package:
individually: true
patterns:
- '!node_modules/**'
- '!**/venv/**'
- '!**/.venv/**'
- '!**/cov_html/**'
- '!**/tests/**'
- '!**/.idea/**'
- '!**/.mypy_cache/**'
- '!**/.pytest_cache/**'
functions:
api:
handler: collector.mangum.handler
module: collector
# Can take a little bit to create a DynamoDB table if necessary
timeout: 30
events:
- http:
path: /
method: get
cors: true
- http:
path: /{proxy+}
method: get
cors: true
- http:
path: /button/{proxy+}
method: ANY
# https://forum.serverless.com/t/cors-problem-when-using-custom-authorizer/11266/2
cors:
origin: '*'
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
allowCredentials: true
authorizer:
name: auth
type: request
# TODO: Change ttl to something > 0. This seems to break CORS, though
resultTtlInSeconds: 0
- http:
path: /web/{proxy+}
method: ANY
# https://forum.serverless.com/t/cors-problem-when-using-custom-authorizer/11266/2
cors:
origin: '*'
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
allowCredentials: true
authorizer:
name: auth
type: request
resultTtlInSeconds: 0
environment:
KINESIS_STREAM: ${opt:stage}-serverless-event-collector
auth:
handler: main.handler
module: authorizer
fan_out:
handler: main.handler
module: fan_out
timeout: 600
events:
- s3:
bucket: ${self:custom.kinesis.bucket}
event: s3:ObjectCreated:*
rules:
- prefix: ${self:custom.kinesis.prefix}
# The bucket gets created in the resources yml, so we need to specify that
# it already exists here. Otherwise, serverless will try to create it again
# and will run into an error because it already exists.
existing: true
custom:
kinesis:
bucket: ${opt:stage}-serverless-event-collector
prefix: raw/
pythonRequirements:
dockerizePip: non-linux
useDownloadCache: true
useStaticCache: true
resources: ${file(resources.yml)}