This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
executable file
·217 lines (188 loc) · 6.53 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
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
service: twilio-webhook-muxer
provider:
name: aws
runtime: python3.7
# The default stage is the "local" stage; CI can deploy other stages (dev and prod)
stage: local
# We use us-west-2 as our AWS region
region: us-west-2
# 30-second timeout by default
timeout: 30
# Tags that will be added to each of the deployment resources
tags:
env: ${self:custom.stage}
# Environment variables
environment:
# Sentry integration: sends Lambda errors to Sentry. Remove this if you don't want to
# use Sentry
SENTRY_DSN: ${ssm:twilio-webhook-muxer.common.sentry_dsn~true}
SENTRY_ENVIRONMENT: ${self:custom.stage}
# Your Twilio credentials, used to verify the Twilio signature and re-sign
# the payload
TWILIO_SID: ${ssm:twilio-webhook-muxer.common.twilio_sid~true}
TWILIO_AUTH_TOKEN: ${ssm:twilio-webhook-muxer.common.twilio_auth_token~true}
# This is the URL this webhook handler is deployed at. We need this to
# verify the Twilio webhook signature. If you're using a custom domain,
# you shouldn't need to change this, but if you've deleted the
# custom domain configuration below you'll need to set this to your
# API Gateway-provided domain name.
TWILIO_CALLBACK_URL: https://${self:custom.customDomain.domainName}/muxer
# The list of downstream targets to forward the webhooks to. Configure this
# in the `custom` section below.
#
# If you are deploying without Serverless and setting this env var manually,
# this must be a base64-encoded JSON blob (we base64-encode because on
# Lambda, env vars can't contain commas)
DOWNSTREAM_CONFIG: ${self:custom.downstreamConfig.${self:custom.stage}}
# Memory allocated to each lambda function
memorySize: 256
package:
exclude:
- 'node_modules/**'
- '.vscode/**'
- '.mypy_cache/**'
- 'package.json'
- 'yarn.lock'
plugins:
# This plugin installs our python dependencies, using docker to properly compile
# them for Lambda
- serverless-python-requirements
# Clean up old versions so we don't exceed our code storage quota
- serverless-prune-plugin
# Datadog integration: remove this if you don't use datadog
- serverless-plugin-datadog
# Custom domains: remove this to use an API Gateway-provided domain instead
- serverless-domain-manager
# This takes the DOWNSTREAM_CONFIG env var above, serializes it as JSON,
# and then base64-encodes it. This is required because Lambda environment
# variables must be strings and cannot contain ",".
- serverless-plugin-encode-env-var-objects
custom:
# The downstream URLs to sent to. Different per-environment. See the README
# for the schema.
downstreamConfig:
local:
default:
downstreams: ["https://fuzzy-va.ngrok.io/other", "https://fuzzy-va.ngrok.io/post"]
responder: 1
keywords:
STOP:
downstreams: ["https://fuzzy-va.ngrok.io/stop"]
responder: null
alternates:
- stip
HELP:
downstreams: ["https://fuzzy-va.ngrok.io/help"]
responder: 0
staging:
default:
downstreams:
- https://helpline-staging.voteamerica.io/twilio-pull
- https://api-staging.voteamerica.com/v1/smsbot/twilio/
responder: 0
keywords:
STOP:
downstreams:
- https://helpline-staging.voteamerica.io/twilio-pull
- https://api-staging.voteamerica.com/v1/smsbot/twilio/
- https://actionnetwork.org/groups/inbound_messages?group_id=160798
responder: null
alternates:
- stip
HELP:
downstreams:
- https://api-staging.voteamerica.com/v1/smsbot/twilio/
responder: 0
JOIN:
downstreams:
- https://api-staging.voteamerica.com/v1/smsbot/twilio/
responder: 0
prod:
default:
downstreams:
- https://helpline-prod.voteamerica.io/twilio-pull
- https://api.voteamerica.com/v1/smsbot/twilio/
responder: 0
keywords:
STOP:
downstreams:
- https://helpline-prod.voteamerica.io/twilio-pull
- https://api.voteamerica.com/v1/smsbot/twilio/
- https://actionnetwork.org/groups/inbound_messages?group_id=158487
responder: 1
alternates:
- stip
- srop
- stop text
- stop texting
- stop texting please
- stop texting me
- stop texting me please
- stop all
- please stop
- please stop texting
- please stop texting me
- stop please
- stop now
- stop ✋
- 🛑
- stop 🛑
- remove
- unsubscribe
- fucking stop
- fuck off
- screw off
- leave me alone
- leave me the fuck alone
HELP:
downstreams:
- https://api.voteamerica.com/v1/smsbot/twilio/
responder: 0
JOIN:
downstreams:
- https://api.voteamerica.com/v1/smsbot/twilio/
responder: 0
# The custom domain name to use for the muxer. You can remove this and
# the serverless-domain-manager plugin to use an API Gateway-provided domain
# instead.
customDomain:
domainName: twilio-muxer-${self:custom.stage}.voteamerica.io
# Specify how to build our python dependencies, and which ones are
# already available in Lambda and don't need to be bundled with the
# application
pythonRequirements:
dockerizePip: true
noDeploy: [
'boto3',
'botocore',
'docutils',
'jmespath',
'python-dateutil',
's3transfer',
'six',
'pip',
'setuptools'
]
# Make stage/region accessible to other parts of the config
stage: ${opt:stage, self:provider.stage}
region: ${opt:region, self:provider.region}
# Configure DataDog integration. If you've removed serverless-plugin-datadog
# above, you can remove this. flushMetricsToLogs requires that you have
# the datadog forwarder installed; see
# https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring#installation
# for details.
datadog:
flushMetricsToLogs: true
# Automatically remove old function versions to avoid filling up your lambda code storage
# quota.
prune:
automatic: true
number: 3
functions:
muxer:
handler: app.muxer.handler
events:
- http:
method: POST
integration: lambda-proxy
path: /muxer