-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
173 lines (163 loc) · 4.89 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
service: template
plugins:
- serverless-nested-stack # Breaks CloudFormation into sub-parts, increase endpoint limit
#- serverless-pseudo-parameters
#- serverless-plugin-tracing # X-Ray
#- serverless-domain-manager
- serverless-api-compression # Enable Response Compression
#- serverless-api-gateway-caching # Enable API Caching - use middy-middleware-cache-redis instead
- serverless-plugin-warmup # Pre-Warm Requests
- serverless-plugin-existing-s3 # Prevent creation of S3 Buckets, already exist
- serverless-mocha-plugin # Integration testing
#- serverless-offline-scheduler
- serverless-offline-sns # Local testing of SNS Events
- serverless-offline # Local testing of HTTP Events, needs to be last in the list
custom:
env: "${file(.env)}"
stage: ${opt:stage, 'development'}
region: ${opt:region, 'us-east-1'}
apiGatewayCaching:
enabled: true
clusterSize: '0.5' # 1.6, 6.1
dataEncrypted: true
ttlInSeconds: 3600
perKeyInvalidation:
requireAuthorization: true
handleUnauthorizedRequests: Ignore
authorizer:
name: authorizer
resultTtlInSeconds: 0
cors:
origin: '*'
headers:
- Authorization
- Content-Type
- X-Amz-Date
- X-Amz-Security-Token
- X-Amz-User-Agent
- X-Api-Key
allowCredentials: false
contentEncoding:
contentCompression: 1400
vpc:
securityGroupIds:
- "${ssm:/vpc/security_group~true}"
subnetIds: { 'Fn::Split': [ ",", "${ssm:/vpc/private_subnets~true}" ] }
warmup:
enabled: false
events:
- schedule: 'cron(0/15 * ? * MON-FRI *)'
prewarm: true
vpc: true
serverless-offline:
port: 3000
serverless-offline-sns:
port: 4002
debug: true
provider:
name: aws
runtime: nodejs10.x
stage: ${self:custom.stage}
region: ${self:custom.region}
endpointType: REGIONAL
versionFunctions: true
environment:
NODE_ENV: ${self:custom.stage}
apiKeys:
- "${self:service}-${self:custom.stage}-testing"
# Required for RDS Access
vpc: "${self:custom.vpc}"
iamRoleStatements:
# serverless-plugin-warmup
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
Resource:
- Fn::Join:
- ':'
- - arn:aws:lambda
- Ref: AWS::Region
- Ref: AWS::AccountId
- function:${self:service}-${opt:stage, self:provider.stage}-*
# Massive hack to prevent `EMFILE: too many open files, scandir` and `Unzipped size must be smaller than 262144000 bytes`
package:
individually: false
excludeDevDependencies: true
exclude:
- ./**
include:
- package.json
- node_modules/**
- '!node_modules/@commitlint/**'
- '!node_modules/husky/**'
- '!node_modules/lint-staged/**'
- '!node_modules/mocha/**'
- '!node_modules/prettier-standard-cli/**'
- '!node_modules/serverless/**'
- '!node_modules/serverless-*/**'
- '!node_modules/standard-version/**'
- src/**
functions:
# authorizer:
# handler: src/handlers/authorizer-auth0.handler
# description: Authorize API requests
#environmentVariables:
# AUTH0_CLIENT_ID: ${self.custom.environment.AUTH0_CLIENT_ID}
# AUTH0_CLIENT_SECRET: ${self.custom.environment.AUTH0_CLIENT_SECRET}
health:
description: Used for health checks
memorySize: 128
timeout: 30
handler: src/handlers/health.handler
warmup:
enabled: true
concurrency: 1
events:
- http:
path: health
method: GET
cors: ${self:custom.cors}
caching:
enabled: true
ttlInSeconds: 300
test-cache:
description: test endpoint to verify caching is working
test-compression:
description: test endpoint to verify compression is working
sample:
description: sample to show how to apply IAM to a lambda
memorySize: 128
timeout: 30
handler: src/handlers/health.handler
events:
- http:
path: sample
method: GET
cors: ${self:custom.cors}
caching:
enabled: true
ttlInSeconds: 300
iamRoleStatements:
- Effect: 'Allow'
Action: 'ssm:GetParametersByPath'
Resource:
- 'arn:aws:ssm:${self:custom.region}:#{AWS::AccountId}:parameter/postgres'
- 'arn:aws:ssm:${self:custom.region}:#{AWS::AccountId}:parameter/elasticsearch'
- 'arn:aws:ssm:${self:custom.region}:#{AWS::AccountId}:parameter/redis'
- Effect: 'Allow'
Action: 'TODO ES'
Resource:
- '${ssm:/elasticsearch/arn~true}'
- Effect: 'Allow'
Action:
- 'rds-db:connect'
Resource:
- '${ssm:/postgres/arn~true}'
- Effect: 'Allow'
Action: 'TODO S3'
Resource:
- 'arn:aws:*'
- Effect: 'Allow'
Action: 'TODO DynamoDB'
Resource:
- 'arn:aws:*'