-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
238 lines (209 loc) · 5.54 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
service: coldoutside
useDotenv: true
provider:
name: aws
runtime: nodejs20.x
profile: weather
region: eu-west-2
environment:
NODE_OPTIONS: --enable-source-maps
GEOCODE_TABLE_NAME: GeocodeCacheTable-${sls:stage}
GEOLOCATION_TABLE_NAME: GeolocationCacheTable-${sls:stage}
WEATHER_TABLE_NAME: WeatherCacheTable-${sls:stage}
OPENWEATHERMAP_API_KEY: ${env:OPENWEATHERMAP_API_KEY}
STAGE: ${self:provider.stage}
stage: ${opt:stage, 'local'}
logRetentionInDays: 7
logs:
httpApi: true
httpApi:
disableDefaultEndpoint: true
cors: true
metrics: true
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource:
Fn::GetAtt:
- GeocodeCacheTable
- Arn
- Effect: "Allow"
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource:
Fn::GetAtt:
- GeolocationCacheTable
- Arn
- Effect: "Allow"
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource:
Fn::GetAtt:
- WeatherCacheTable
- Arn
package:
patterns:
- ./app/static/*
- ./app/src/**/*.(js|ts|liquid)
plugins:
- serverless-better-credentials
- serverless-esbuild
- serverless-dynamodb
- serverless-certificate-creator
- serverless-domain-manager
- serverless-offline
custom:
domains:
production: api.coldoutsi.de
staging: api.staging.coldoutsi.de
dev: api.dev.coldoutsi.de
disableIfLocal:
local: false
customCertificate:
enabled: ${self:custom.disableIfLocal.${sls:stage}, true}
certificateName: ${self:custom.domains.${sls:stage}, null}
hostedZoneNames: "coldoutsi.de."
region: ${self:provider.region}
tags:
Name: "api.coldoutsi.de"
Environment: ${sls:stage}
customDomain:
enabled: ${self:custom.disableIfLocal.${sls:stage}, true}
domainName: ${self:custom.domains.${sls:stage}, null}
certificateName: ${self:custom.customCertificate.certificateName, null}
createRoute53Record: true
createRoute53IPv6Record: true
endpointType: REGIONAL
securityPolicy: tls_1_2
apiType: http
autoDomain: true
stage: "$default"
serverless-dynamodb:
stages:
- local
start:
port: 8000
inMemory: true
migrate: true
esbuild:
outputFileExtension: .mjs
format: esm
sourcemap: true
banner:
js: |
import { createRequire as topLevelCreateRequire } from 'module';
const require = topLevelCreateRequire(import.meta.url);
serverless-offline:
host: "127.0.0.1"
functions:
# Always make sure the matched paths are distinct. Put more specific paths
# first.
static:
handler: ./app/src/handlers/static/index.staticHandler
events:
- httpApi:
path: /static/{path}
method: GET
- httpApi:
path: /favicon.ico
method: GET
index:
handler: ./app/src/handlers/static/index.indexHandler
events:
- httpApi:
path: /
method: GET
- httpApi:
path: /metno
method: GET
test:
handler: ./app/src/handlers/test/index.testHandler
events:
- httpApi:
path: /test
method: GET
unknown:
handler: ./app/src/handlers/unknown/index.unknownHandler
events:
- httpApi:
path: "/:unknown"
method: GET
- httpApi:
path: "/metno/:unknown"
method: GET
reverseWeatherMetno:
handler: ./app/src/handlers/weather/index.reverseMetnoWeatherHandler
events:
- httpApi:
path: /metno/{lat}/{lon}
method: GET
weatherMetno:
handler: ./app/src/handlers/weather/index.metnoWeatherHandler
events:
- httpApi:
path: /metno/{location}
method: GET
reverseWeather:
handler: ./app/src/handlers/weather/index.reverseWeatherHandler
events:
- httpApi:
path: /{lat}/{lon}
method: GET
weather:
handler: ./app/src/handlers/weather/index.weatherHandler
events:
- httpApi:
path: /{location}
method: GET
resources:
Resources:
GeolocationCacheTable:
Type: "AWS::DynamoDB::Table"
Properties:
TableName: ${self:provider.environment.GEOLOCATION_TABLE_NAME}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: ip
AttributeType: S
KeySchema:
- AttributeName: ip
KeyType: HASH
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
GeocodeCacheTable:
Type: "AWS::DynamoDB::Table"
Properties:
TableName: ${self:provider.environment.GEOCODE_TABLE_NAME}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: geoHash
AttributeType: S
- AttributeName: acceptLanguage
AttributeType: S
KeySchema:
- AttributeName: geoHash
KeyType: HASH
- AttributeName: acceptLanguage
KeyType: RANGE
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
WeatherCacheTable:
Type: "AWS::DynamoDB::Table"
Properties:
TableName: WeatherCacheTable-${sls:stage}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: weatherHash
AttributeType: S
KeySchema:
- AttributeName: weatherHash
KeyType: HASH
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true