forked from cityofaustin/ctxfloods-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
189 lines (174 loc) · 5.04 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
service: ${env:AWS_SERVICE_NAME}
plugins:
- serverless-content-encoding
- serverless-webpack
custom:
contentEncoding:
minimumCompressionSize: 0
webpack:
webpackConfig: 'webpack.config.js'
packager: 'yarn'
keepOutputDirectory: true
PG_ENDPOINT:
Fn::GetAtt:
- pgDB
- Endpoint.Address
GRAPHQL_ENDPOINT:
Fn::Join:
- ''
- - 'https://'
- Ref: ApiGatewayRestApi
- '.execute-api.'
- ${self:provider.region}
- .amazonaws.com/
- ${self:provider.stage}
- /graphql
false: false
package:
individually: true
provider:
name: aws
runtime: nodejs8.10
deploymentBucket:
name: ${env:AWS_SERVICE_NAME}
environment:
NODE_ENV: ${env:NODE_ENV}
BACKEND_PORT: ${env:BACKEND_PORT}
PG_PORT: ${env:PG_PORT}
PG_API_USR: ${env:PG_API_USR}
PG_API_PW: ${env:PG_API_PW}
GRAPHQL_API_USR: ${env:GRAPHQL_API_USR}
GRAPHQL_API_PW: ${env:GRAPHQL_API_PW}
region: us-east-1
stage: ${env:AWS_STAGE}
functions:
graphql:
handler: handlers/graphqlHandler.handle
events:
- http:
method: post
path: graphql
cors: true
integration: lambda-proxy
environment:
PG_ENDPOINT: ${self:custom.PG_ENDPOINT}
JWT_SECRET: ${env:JWT_SECRET}
DISABLE_QUERY_LOG: ${env:DISABLE_QUERY_LOG}
xml:
handler: handlers/xmlHandler.handle
events:
- http:
method: get
path: xml
environment:
PG_ENDPOINT: ${self:custom.PG_ENDPOINT}
waze_feed:
handler: handlers/wazeFeedHandler.handle
events:
- http:
method: get
path: waze/feed
environment:
PG_ENDPOINT: ${self:custom.PG_ENDPOINT}
incidentreport:
handler: handlers/incidentReportHandler.handle
events:
- http:
method: post
path: incident/report
cors: true
environment:
GRAPHQL_ENDPOINT: ${self:custom.GRAPHQL_ENDPOINT}
GMAIL_ADDRESS: ${env:GMAIL_ADDRESS}
GMAIL_CLIENT_ID: ${env:GMAIL_CLIENT_ID}
GMAIL_CLIENT_SECRET: ${env:GMAIL_CLIENT_SECRET}
GMAIL_REFRESH_TOKEN: ${env:GMAIL_REFRESH_TOKEN}
emailreset:
handler: handlers/resetEmailHandler.handle
events:
- http:
method: post
path: email/reset
cors: true
environment:
PG_ENDPOINT: ${self:custom.PG_ENDPOINT}
JWT_SECRET: ${env:JWT_SECRET}
GMAIL_ADDRESS: ${env:GMAIL_ADDRESS}
GMAIL_CLIENT_ID: ${env:GMAIL_CLIENT_ID}
GMAIL_CLIENT_SECRET: ${env:GMAIL_CLIENT_SECRET}
GMAIL_REFRESH_TOKEN: ${env:GMAIL_REFRESH_TOKEN}
synclegacy:
handler: handlers/syncLegacyHandler.handle
timeout: 60
events:
- schedule:
rate: rate(5 minutes)
enabled: ${env:ENABLE_SYNC_LEGACY, self:custom.false}
environment:
GRAPHQL_ENDPOINT: ${self:custom.GRAPHQL_ENDPOINT}
pushNotifications:
handler: handlers/pushNotificationHandler.handle
timeout: 60
events:
- schedule:
rate: cron(0 12 * * ? *)
enabled: ${env:ENABLE_PUSH_NOTIFICATIONS, self:custom.false}
environment:
GRAPHQL_ENDPOINT: ${self:custom.GRAPHQL_ENDPOINT}
PG_ENDPOINT: ${self:custom.PG_ENDPOINT}
AWS_SERVICE_NAME: ${env:AWS_SERVICE_NAME}
GMAIL_ADDRESS: ${env:GMAIL_ADDRESS}
GMAIL_CLIENT_ID: ${env:GMAIL_CLIENT_ID}
GMAIL_CLIENT_SECRET: ${env:GMAIL_CLIENT_SECRET}
GMAIL_REFRESH_TOKEN: ${env:GMAIL_REFRESH_TOKEN}
scrapeCameras:
handler: handlers/cameraScrapeHandler.handle
timeout: 60
events:
- schedule:
rate: rate(5 minutes)
enabled: true
environment:
GRAPHQL_ENDPOINT: ${self:custom.GRAPHQL_ENDPOINT}
AUSTIN_DATA_APP_TOKEN: ${env:AUSTIN_DATA_APP_TOKEN}
# For a pgDB inside a VPC look e.g. here:
# http://www.stojanveselinovski.com/blog/2016/01/12/simple-postgresql-rds-cloudformation-template/
resources:
Resources:
pgSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Access to Postgres
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '5432'
ToPort: '5432'
CidrIp: 0.0.0.0/0
pgDB:
Type: 'AWS::RDS::DBInstance'
Properties:
DBName: 'postgres'
BackupRetentionPeriod: ${env:DB_BACKUP_RETENTION_PERIOD}
AllocatedStorage: 5
DBInstanceClass: 'db.t2.micro'
DeletionProtection: ${env:DB_DELETION_PROTECTION, self:custom.false}
AllowMajorVersionUpgrade: true
Engine: 'postgres'
EngineVersion: '10.6'
MasterUsername: ${env:PG_MASTER_USR}
MasterUserPassword: ${env:PG_MASTER_PW}
VPCSecurityGroups:
- Fn::GetAtt:
- pgSecurityGroup
- GroupId
Tags:
- Key: 'Name'
Value: 'floods'
DeletionPolicy: 'Snapshot'
Outputs:
PgEndpoint:
Description: 'JDBC connection string for database'
Value: ${self:custom.PG_ENDPOINT}
GraphqlEndpoint:
Description: 'URL of /graphql Endpoint'
Value: ${self:custom.GRAPHQL_ENDPOINT}