forked from livgust/covid-vaccine-scrapers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
274 lines (264 loc) · 8.07 KB
/
template.yaml
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: macovidvaccines
Parameters:
Environment:
Type: String
Description: Which environment do you want to deploy to? (stage or prod)
AllowedValues:
- stage
- prod
Default: stage
GoogleApiKey:
Type: String
WalgreensEmail:
Type: String
WalgreensPassword:
Type: String
WalgreensChallenge:
Type: String
WalgreensApiKey:
Type: String
FaunaApiKey:
Type: String
NodeEnv:
Type: String
BucketName:
Type: String
RecaptchaToken:
Type: String
SlackWebhook:
Type: String
TwitterApiKey:
Type: String
TwitterApiSecret:
Type: String
TwitterAccessTokenKey:
Type: String
TwitterAccessTokenSecret:
Type: String
PinpointApplicationId:
Type: String
PinpointOriginationNumber:
Type: String
Globals:
Function:
Timeout: 180
Resources:
MACovidVaccinesApi:
Type: AWS::Serverless::Api
Properties:
StageName: !Sub "${Environment}"
MinimumCompressionSize: 1000
CacheClusterEnabled: true
CacheClusterSize: "0.5"
Cors:
AllowMethods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
MethodSettings:
- HttpMethod: GET
CacheTtlInSeconds: 5
ResourcePath: "/appointment_availability"
CachingEnabled: true
MACovidVaccineScraper:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "MACovidVaccineScraperFunction-${Environment}"
Handler: scraper.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 2048
Timeout: 300
Policies:
- AWSLambdaBasicExecutionRole
- CloudWatchPutMetricPolicy: {}
- S3CrudPolicy:
BucketName: "*"
- LambdaInvokePolicy:
FunctionName: !Ref MACovidVaccineAlerts
Environment:
Variables:
GOOGLE_API_KEY: !Ref GoogleApiKey
WALGREENS_EMAIL: !Ref WalgreensEmail
WALGREENS_PASSWORD: !Ref WalgreensPassword
WALGREENS_CHALLENGE: !Ref WalgreensChallenge
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
AWSS3BUCKETNAME: !Ref BucketName
RECAPTCHATOKEN: !Ref RecaptchaToken
SLACKWEBHOOKBOTCHANNEL: !Ref SlackWebhook
ALERTSFUNCTIONNAME: !Ref MACovidVaccineAlerts
Events:
ScraperSchedule:
Type: Schedule
Properties:
Schedule: rate(1 minute)
MACovidVaccineNoBrowserScraper:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "MACovidVaccineNoBrowserScraperFunction-${Environment}"
Handler: scrapers_no_browser.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 2048
Timeout: 180
Policies:
- AWSLambdaBasicExecutionRole
- CloudWatchPutMetricPolicy: {}
- S3CrudPolicy:
BucketName: "*"
- LambdaInvokePolicy:
FunctionName: !Ref MACovidVaccineAlerts
Environment:
Variables:
GOOGLE_API_KEY: !Ref GoogleApiKey
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
AWSS3BUCKETNAME: !Ref BucketName
SLACKWEBHOOKBOTCHANNEL: !Ref SlackWebhook
ALERTSFUNCTIONNAME: !Ref MACovidVaccineAlerts
Events:
ScraperSchedule:
Type: Schedule
Properties:
Schedule: rate(1 minute)
GetMACovidVaccineScraperData:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "GetMACovidVaccineScraperDataFunction-${Environment}"
Handler: getScraperData.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 256
Timeout: 20
Policies:
- AWSLambdaBasicExecutionRole
- S3ReadPolicy:
BucketName: "*"
Environment:
Variables:
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
Events:
GetMACovidVaccineScraperDataApi:
Type: Api
Properties:
RestApiId: !Ref MACovidVaccinesApi
Method: GET
Path: /appointment_availability
MACovidVaccineAlerts:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "MACovidVaccineAlertsFunction-${Environment}"
Handler: alerts/alerts.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 256
Timeout: 60
Policies:
- AWSLambdaBasicExecutionRole
- CloudWatchPutMetricPolicy: {}
- LambdaInvokePolicy:
FunctionName: !Ref TextAndEmailSender
Environment:
Variables:
GOOGLE_API_KEY: !Ref GoogleApiKey
FAUNA_DB: !Ref FaunaApiKey
SLACKWEBHOOKBOTCHANNEL: !Ref SlackWebhook
TWITTER_API_KEY: !Ref TwitterApiKey
TWITTER_API_SECRET: !Ref TwitterApiSecret
TWITTER_ACCESS_TOKEN_KEY: !Ref TwitterAccessTokenKey
TWITTER_ACCESS_TOKEN_SECRET: !Ref TwitterAccessTokenSecret
NODE_ENV: !Ref NodeEnv
PINPOINTFUNCTIONNAME: !Ref TextAndEmailSender
SMSRouter:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "SMSRouter-${Environment}"
Handler: ./alerts/pinpoint/router.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 256
Timeout: 5
Policies:
- AWSLambdaBasicExecutionRole
- PinpointEndpointAccessPolicy:
PinpointApplicationId: !Ref PinpointApplicationId
- Version: "2012-10-17" # Policy Document
Statement:
- Effect: Allow
Action:
- mobiletargeting:PhoneNumberValidate
- mobiletargeting:SendMessages
Resource: "*"
Environment:
Variables:
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
PINPOINT_APPLICATION_ID: !Ref PinpointApplicationId
PINPOINT_ORIGINATION_NUMBER: !Ref PinpointOriginationNumber
Events:
SNSEvent:
Type: SNS
Properties:
Topic: arn:aws:sns:us-east-1:952391375996:macovidvaccinesAlertsSNS
AddSubscription:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "AddSubscription-${Environment}"
Handler: ./alerts/sign_up.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 256
Timeout: 5
Policies:
- AWSLambdaBasicExecutionRole
- PinpointEndpointAccessPolicy:
PinpointApplicationId: !Ref PinpointApplicationId
- Version: "2012-10-17" # Policy Document
Statement:
- Effect: Allow
Action:
- mobiletargeting:PhoneNumberValidate
- mobiletargeting:SendMessages
Resource: "*"
Environment:
Variables:
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
PINPOINT_APPLICATION_ID: !Ref PinpointApplicationId
PINPOINT_ORIGINATION_NUMBER: !Ref PinpointOriginationNumber
Events:
AddSubscriptionApi:
Type: Api
Properties:
RestApiId: !Ref MACovidVaccinesApi
Method: POST
Path: /subscription
TextAndEmailSender:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "TextAndEmailSender-${Environment}"
Handler: ./alerts/send_texts_and_emails.handler
Runtime: nodejs14.x
CodeUri: .
MemorySize: 256
Timeout: 180
Policies:
- AWSLambdaBasicExecutionRole
- PinpointEndpointAccessPolicy:
PinpointApplicationId: !Ref PinpointApplicationId
- Version: "2012-10-17" # Policy Document
Statement:
- Effect: Allow
Action:
- mobiletargeting:PhoneNumberValidate
- mobiletargeting:SendMessages
Resource: "*"
Environment:
Variables:
FAUNA_DB: !Ref FaunaApiKey
NODE_ENV: !Ref NodeEnv
PINPOINT_APPLICATION_ID: !Ref PinpointApplicationId
PINPOINT_ORIGINATION_NUMBER: !Ref PinpointOriginationNumber