-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
160 lines (148 loc) · 4.37 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
service: nzshm22-kororaa-api
plugins:
- serverless-python-requirements
- serverless-wsgi
- serverless-s3-local
- serverless-plugin-warmup
package:
individually: false
patterns:
- '!__pycache__/**'
- '!.git/**'
- '!.github/**'
- '!.pytest_cache/**'
- '!.mypy_cache/**'
- '!.tox/**'
- '!dist/**'
- '!docs/**'
- '!/**'
- '!node_modules/**'
- '!package.json'
- '!package-log.json'
- '!tests/**'
- '!site/**'
- kororaa_graphql_api/**
custom:
#serverless-wsgi settings
wsgi:
app: kororaa_graphql_api.kororaa_graphql_api.app
packRequirements: false
pythonBin: python3
#serverless-python-requirements settings
pythonRequirements:
# dockerizePip: non-linux
slim: true
slimPatterns:
- '**/*.egg-info*'
noDeploy:
- boto3
- botocore
- fiona
- Fiona.libs
#serverless-s3-local settings
s3:
host: localhost
directory: /tmp
# Lambda warmer see https://www.serverless.com/plugins/serverless-plugin-warmup
warmup:
littleWarmer:
enabled: true
events:
- schedule: rate(5 minutes)
concurrency: 1
# DRY constants: define all compound/generated names in one place
# Override args are: .. defaults:
# --app_acroym signed-uploader
# --s3_bucket self:custom.app_acronym
# --s3_key_base self:custom.stage
# --region us-east-1
# --stage test
# --deletion_policy delete
app_acronym: ${opt:acronym, self:service}
default_stage: local
stage: ${opt:stage, self:custom.default_stage}
stack_name: ${self:custom.app_acronym}-${self:custom.stage}
region: ${opt:region, self:provider.region}
deletion_policy: Delete
# presigned URL TTL
url_default_ttl: 60
# Default to using app_acronym as bucket name
s3_bucket: ${opt:s3_bucket, self:custom.app_acronym}-${self:custom.stage}
# default to using ${stage} as key base path, keeps stages from namespace collisions
s3_bucket_arn: arn:aws:s3:::${self:custom.s3_bucket}
s3_role_resource: ${self:custom.s3_bucket_arn}
provider:
name: aws
runtime: python3.10
stage: ${opt:stage, 'dev'}
region: ap-southeast-2
apiGateway:
apiKeys:
- name: KoraraaTempApiKey-${self:custom.stage}
description: Api key until we have an auth function # Optional
iam:
role:
statements:
- Effect: Allow
Action:
- "cloudwatch:PutMetricData"
Resource: "*"
- Effect: Allow
Action:
- "dynamodb:Scan"
- "dynamodb:DescribeTable"
- "dynamodb:GetItem"
- "dynamodb:ConditionCheckItem"
- "dynamodb:Query"
Resource:
- "arn:aws:dynamodb:ap-southeast-2:461564345538:table/THS_HazardAggregation-PROD"
- "arn:aws:dynamodb:ap-southeast-2:461564345538:table/THS_GriddedHazard-PROD"
- Effect: Allow
Action:
- s3:*
Resource:
- ${self:custom.s3_role_resource}
- ${self:custom.s3_role_resource}/*
functions:
app:
description: The graphql API of ${self:service}
handler: wsgi_handler.handler
memorySize: 2096 # optional, in MB, default is 1024
timeout: 20 # optional, in seconds, default is 6
events:
- http:
path: graphql
method: OPTIONS
- http:
path: graphql
method: POST
private: true
- http:
path: graphql
method: GET
private: true
environment:
STACK_NAME: ${self:custom.stack_name}
REGION: ${self:custom.region}
URL_DEFAULT_TTL: ${self:custom.url_default_ttl}
DEPLOYMENT_STAGE: ${self:custom.stage}
ENABLE_METRICS: ${env:ENABLE_METRICS, 0}
COLOR_SCALE_NORMALISATION: ${env:COLOR_SCALE_NORMALISATION, 'LIN'}
S3_BUCKET_NAME: ${self:custom.s3_bucket}
NZSHM22_HAZARD_STORE_STAGE: PROD
NZSHM22_HAZARD_STORE_REGION: ${self:custom.region}
DISAGGS_KEY: "DISAGGS/disaggs.json"
PUBLICATIONS_KEY: "PUBLICATIONS/nshm_science_reports_metadata_table.json"
TEXT_CONTENT_INDEX_KEY: "TEXT_CONTENT/text_content_index.json"
TEXT_CONTENT_FOLDER_KEY: "TEXT_CONTENT"
warmup:
littleWarmer:
enabled:
- test
- prod
resources:
Resources:
KororaaApiBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.s3_bucket}