-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.dist.yml
166 lines (158 loc) · 4.87 KB
/
serverless.dist.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
# See docs for full reference
# https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/
service: ''
# app and org for use with dashboard.serverless.com
#app: ''
#org: ''
provider:
name: aws
runtime: python3.9
stage: ${opt:stage, self:custom.defaultStage}
profile: ${self:custom.stage_vars.${self:provider.stage}.aws_profile}
deploymentBucket:
maxPreviousDeploymentArtifacts: 10
blockPublicAccess: true
iamRoleStatements:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource: ${cf:unemployment-reminders-${self:provider.stage}.SecretsArn}
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:*:*:table/${self:custom.dynamo_db_table}"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
Resource: "arn:aws:dynamodb:*:*:table/${self:custom.dynamo_db_table}/index/*"
custom:
defaultStage: dev
dynamo_db_table: unemployment-reminders
stage_vars:
dev:
aws_profile: ''
bot_base_url: ''
bot_sms_number: ''
custom_domain: ''
stage:
aws_profile: ''
bot_base_url: ''
bot_sms_number: ''
custom_domain: ''
prod:
aws_profile: ''
bot_base_url: ''
bot_sms_number: ''
custom_domain: ''
# WSGI Plugin: https://github.com/logandk/serverless-wsgi
wsgi:
app: src/wsgi.app
pythonBin: python3
packRequirements: false
# DynamoDB Local Plugin: https://github.com/99xt/serverless-dynamodb-local
dynamodb:
# We are using a separate container for this
# https://github.com/99xt/serverless-dynamodb-local/issues/57#issuecomment-507005352
start:
host: dynamodb
port: 8000
noStart: true
seed:
init:
sources:
- table: ${self:custom.dynamo_db_table}
sources: [./data/dynamo.seed.init.json]
stages:
- dev
# Custom Domain Plugin: https://github.com/amplify-education/serverless-domain-manager
customDomain:
domainName: ${self:custom.stage_vars.${self:provider.stage}.custom_domain}
basePath: ''
stage: ${self:provider.stage}
createRoute53Record: true
plugins:
- serverless-domain-manager
- serverless-wsgi
- serverless-python-requirements
- serverless-dynamodb-local
package:
individually: false
include:
- '!./**'
- 'src/**'
exclude:
- '**'
functions:
api:
handler: wsgi_handler.handler
events:
- http: ANY /
- http: ANY /{proxy+}
timeout: 10
memorySize: 1024
environment:
FLASK_ENV: ${self:provider.stage}
SECRETS_MANAGER_SECRET_ARN: ${cf:unemployment-reminders-${self:provider.stage}.SecretsArn}
BOT_BASE_URL: ${self:custom.stage_vars.${self:provider.stage}.bot_base_url}
BOT_SMS_NUMBER: ${self:custom.stage_vars.${self:provider.stage}.bot_sms_number}
API_GATEWAY_BASE_PATH: ${self:provider.stage}
poller:
handler: src/poller.lambda_handler
events:
# Every 5th minute past every hour from 13 through 17 (UTC) on every day-of-week from Monday through Friday.
- schedule:
rate: cron(*/5 13-17 ? * MON-FRI *)
enabled: true
# This is useful for testing. Disabled by default
- schedule:
rate: rate(1 minute)
enabled: false
timeout: 600
memorySize: 1024
environment:
FLASK_ENV: ${self:provider.stage}
SECRETS_MANAGER_SECRET_ARN: ${cf:unemployment-reminders-${self:provider.stage}.SecretsArn}
BOT_SMS_NUMBER: ${self:custom.stage_vars.${self:provider.stage}.bot_sms_number}
resources:
Resources:
RemindersDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
# E.164 phone number. https://www.twilio.com/docs/glossary/what-e164
- AttributeName: phone_number
AttributeType: S
# UTC ISO 8601 date
- AttributeName: next_alert_at
AttributeType: S
# 1,0 Flag the alert as in progress
- AttributeName: in_progress
AttributeType: N
BillingMode: PAY_PER_REQUEST
GlobalSecondaryIndexes:
- IndexName: gsi_queue
KeySchema:
- AttributeName: in_progress
KeyType: HASH
- AttributeName: next_alert_at
KeyType: RANGE
Projection:
NonKeyAttributes:
# monday, tuesday, wednesday, thursday, friday
- alert_day
# America/Chicago
- timezone
# UTC ISO 8601 date.
- alert_time
ProjectionType: INCLUDE
KeySchema:
- AttributeName: phone_number
KeyType: HASH
TableName: ${self:custom.dynamo_db_table}