-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathserverless.yml
More file actions
217 lines (209 loc) · 7.08 KB
/
serverless.yml
File metadata and controls
217 lines (209 loc) · 7.08 KB
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
service: internal-spoke
frameworkVersion: ">=1.0.0 <2.0.0"
custom:
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
baseUrl:
dev: https://${self:custom.customDomain.domainName}
prod: https://spoke.elizabethwarren.com
debugApollo:
dev: 1
prod: 0
reservedConcurrency:
dev: 100
prod: 1000
# uncomment suppressPhoneValidation, dropMessageRatio
# and skipTwilioAndAutoreply and equivalent env vars below
# suppressPhoneValidation:
# dev: 1
# dropMessageRatio:
# dev: 0.9
# skipTwilioAndAutoReply:
# dev: 1
deploy:
# Users can define these parameters in SSM (they will be looked up at deploy time)
# or in the deploy environment or inline
bucket_name: ${ssm:${BUCKET NAME~true}
bucket_arn: ${ssm:${BUCKET ARN~true}
vpcConfig:
subnetIds:
# Users can define these parameters in SSM (they will be looked up at deploy time)
# or in the deploy environment or inline
- "${ssm:${SUBNET ID}~true}"
...
securityGroupIds:
# Users can define this parameter in SSM (it will be looked up at deploy time)
# or in the deploy environment or inline
- "${ssm:${SECURITY GROUP ID}~true}"
associateWaf:
# OPTIONAL. A WAF is not strictly required, but it is generally useful to have
# one to handle IP-level rate limiting
name: WAF NAME
customDomain:
domainName: "A DOMAIN NAME"
stage: ${self:custom.stage}
certificateName: "*.A DOMAIN NAME"
createRoute53Record: true
securityPolicy: tls_1_2
custom:
prune:
automatic: true
number: 5
provider:
name: aws
runtime: nodejs12.x
deploymentBucket:
name: ${self:custom.deploy.bucket_name}
blockPublicAccess: true
iamRoleStatements:
- Effect: Allow
Action: lambda:InvokeFunction
Resource: "arn:aws:lambda:${self:custom.region}:#{AWS::AccountId}:function:internal-spoke-${self:custom.stage}-worker"
- Effect: Allow
Action:
- "events:PutEvents"
- "cloudwatch:PutMetricData"
Resource: "*"
- Effect: Allow
Action:
- "ses:CreateTemplate"
- "ses:SendEmail"
- "ses:SendTemplatedEmail"
- "ses:UpdateTemplate"
Resource: "*"
- Effect: Allow
Action:
- "s3:*"
Resource:
# Users can define this parameter in SSM (it will be looked up at deploy time)
# or in the deploy environment or inline
- "${ssm:${PRIVATE BUCKET ARN}~true}"
- "${ssm:${PRIVATE BUCKET ARN}~true}/*"
- Effect: Allow
Action:
- codedeploy:*
Resource:
- "*"
environment:
STAGE: ${self:custom.stage}
NODE_ENV: production
STATIC_BASE_URL: /assets/
SUPPRESS_SELF_INVITE: 1
PHONE_NUMBER_COUNTRY: US
SUPPRESS_SEED_CALLS: 1
KNEX_MIGRATION_DIR: ./build/server/migrations
PASSPORT_STRATEGY: slack
AWS_ACCESS_AVAILABLE: 1
DST_REFERENCE_TIMEZONE: America/New_York
DEFAULT_SERVICE: twilio
DB_PORT: 5432
DB_TYPE: pg
EMAIL_ENABLED: true
SES_REGION: us-east-1
CACHE_PREFIX: spoke-
CONTACTS_PER_PHONE_NUMBER: 200
JOB_EXECUTOR: LAMBDA
ASSETS_DIR: ./build/client/assets
ASSETS_MAP_FILE: assets.json
OPTOUTS_SHARE_ALL_ORGS: 1
MAX_CONTACTS: 75000
SLOW_REQUEST_LOG_THRESHOLD: 500
CLOUDWATCH_METRICS_ENABLED: 1
DEBUG_APOLLO: ${self:custom.debugApollo.${self:custom.stage}}
TWILIO_STATUS_CALLBACK_URL: ${self:custom.baseUrl.${self:custom.stage}}/twilio-message-report
JOB_LAMBDA_WORKER_FUNCTION_NAME: internal-spoke-${self:custom.stage}-worker
BASE_URL: ${self:custom.baseUrl.${self:custom.stage}}
ASSET_DOMAIN: https://ew-spoke-public.elizabethwarren.codes/${self:custom.stage}
# Users can define these parameters in SSM (they will be looked up at deploy time)
# or in the deploy environment or inline. Secrets like this are best maintained
# in something like SSM, but careful use of environment variables works here too!
SESSION_SECRET: ${ssm:${SESSION SECRET PARAMETER NAME}~true}
AWS_S3_BUCKET_NAME: ${ssm:${PRIVATE BUCKET NAME}~true}
AUTH0_CLIENT_ID: ${ssm:${AUTH0 CLIENT ID}~true}
AUTH0_CLIENT_SECRET: ${ssm:${AUTHO CLIENT_SECRET}~true}
AUTH0_DOMAIN: ${ssm:${AUTH0 DOMAIN}/DOMAIN}
DB_HOST: ${ssm:${POSTGRES HOST}~true}
DB_NAME: ${ssm:${POSTGRES DB NAME}~true}
DB_USER: ${ssm:${POSTGRES USER}~true}
DB_PASSWORD: ${ssm:${POSTGRES PASSWORD}~true}
EMAIL_FROM: ${ssm:${EMAIL FROM}~true}
EMAIL_REPLY_TO: ${ssm:${EMAIL REPLY TO}~true}
REDIS_URL: redis://${ssm:${REDIS ENDPOINT}~true}:6379/3
TWILIO_ACCOUNT_SID: ${ssm:${TWILIO ACCOUNT SID}~true}
TWILIO_AUTH_TOKEN: ${ssm:${TWILIO AUTH TOKEN}~true}
TWILIO_MESSAGE_SERVICE_SID: ${ssm:${TWILIO MESSAGE SERVICE SID}~true}
TWILIO_VOICE_URL: ${ssm:${TWILIO VOICE URL}~true}
SLACK_CLIENT_ID: ${ssm:${SLACK CLIENT ID}~true}
SLACK_CLIENT_SECRET: ${ssm:${SLACK CLIENT SECRET}~true}
SLACK_TEAM_ID: ${ssm:${SLACK TEAM ID}~true}
EMBEDDED_SHIFTER_URL: ${ssm:${EMBEDDED SHIFTER URL}~true}
SENTRY_DSN: ${ssm:${SENTRY DSN}~true}
# SUPPRESS_PHONE_VALIDATION: 1
# SKIP_TWILIO_AND_AUTOREPLY: ${self:custom.skipTwilioAndAutoReply.${self:custom.stage}}
# DROP_MESSAGE_RATIO: ${self:custom.dropMessageRatio.${self:custom.stage}}
functions:
api:
handler: lambda.handler
vpc: ${self:custom.vpcConfig}
events:
- http: ANY /
- http: ANY {proxy+}
reservedConcurrency: ${self:custom.reservedConcurrency.${self:custom.stage}}
deploymentSettings:
type: Linear10PercentEvery1Minute
alias: Live
preTrafficHook: preflight
postTrafficHook: postflight
dependsOn:
- PreflightLambdaFunction
- PostflightLambdaFunction
worker:
handler: build/server/server/lambda/worker.handler
vpc: ${self:custom.vpcConfig}
timeout: 600
# twilio-webhook:
# handler: build/server/server/lambda/twilio-webhook.handler
# vpc: ${self:custom.vpcConfig}
# events:
# - sqs:
# arn: ${ssm:${self:custom.stage}/spoke/sqs/TWILIO_WEBHOOK_QUEUE_ARN~true}
# batchSize: 1 # TODO: this is for testing, raise it in production
# send-reminders:
# handler: build/server/server/lambda/send-reminders.handler
# vpc: ${self:custom.vpcConfig}
# timeout: 900
# events:
# - schedule: cron(0 1,17 * * ? *)
preflight:
handler: build/server/server/lambda/codedeploy.preflight
vpc: ${self:custom.vpcConfig}
timeout: 600
postflight:
handler: build/server/server/lambda/codedeploy.postflight
vpc: ${self:custom.vpcConfig}
timeout: 600
plugins:
- serverless-domain-manager
- serverless-associate-waf
- serverless-api-compression
- serverless-prune-plugin
- serverless-jetpack
- serverless-plugin-canary-deployments
- serverless-plugin-git-variables
package:
excludeDevDependencies: true
package:
exclude:
- "*"
- "webpack/**"
- ".github/**"
- "dev-tools/**"
- "docs/**"
- "__test__/**"
- "__mocks__/**"
- "**/node_modules/aws-sdk/**" # included on Lambda.
- "!package.json"
- "!lambda.js"
- "!knexfile.js"
- "build/client/assets/*.js"
- "build/client/assets/*.js.map"