-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserverless.yml
More file actions
199 lines (181 loc) · 5.03 KB
/
serverless.yml
File metadata and controls
199 lines (181 loc) · 5.03 KB
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
# "org" ensures this Service is used with the correct Serverless Framework Access Key.
org: gnssciencenshm
# "app" enables Serverless Framework Dashboard features and sharing them with other Services.
app: solvis-graphql-api
service: nzshm22-solvis-graphql-api
configValidationMode: error
plugins:
- serverless-wsgi
- serverless-plugin-warmup
package:
individually: false
patterns:
- '!__pycache__/**'
- '!.git/**'
- '!.github/**'
- '!.pytest_cache/**'
- '!.mypy_cache/**'
- '!.tox/**'
- '!dist/**'
- '!docs/**'
- '!/**'
- '!node_modules/**'
- '!package.json'
- '!package-log.json'
- '!poetry.lock'
- '!tests/**'
- '!**/test/**'
- '!WORKING/**'
- '!.dynamodb/**'
- '!site/**'
- '!*.*'
- '!.pnp.*'
- 'yarn.lock'
- solvis_graphql_api/**
custom:
# 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
s3_bucket: ${opt:s3_bucket, self:custom.app_acronym}-${self:custom.stage}
s3_bucket_arn: arn:aws:s3:::${self:custom.s3_bucket}
s3_role_resource: ${self:custom.s3_bucket_arn}
url_default_ttl: 60 # presigned URL TTL
#serverless-wsgi settings
wsgi:
app: solvis_graphql_api.solvis_graphql_api.app
packRequirements: false
pythonBin: python3.12
#serverless-s3-local settings
s3:
host: localhost
directory: /tmp
serverless-dynamodb:
stages:
- local
start:
# docker: true
port: 8000
inMemory: true
heapInitial: 200m
heapMax: 1g
sharedDb: true
# Lambda warmer settings see https://www.serverless.com/plugins/serverless-plugin-warmup
warmup:
littleWarmer:
enabled: true
events:
- schedule: rate(5 minutes)
concurrency: 1
provider:
name: aws
runtime: python3.12
stage: ${opt:stage, 'dev'}
region: ap-southeast-2
ecr:
# In this section you can define images that will be built locally and uploaded to ECR
images:
app_image_0:
path: "."
file: Dockerfile
buildArgs:
STAGE: ${self:custom.stage}
cacheFrom:
# - my-image:latest
platform: linux/amd64
environment:
REGION: ${self:custom.region}
S3_BUCKET_NAME: ${self:custom.s3_bucket}
URL_DEFAULT_TTL: ${self:custom.url_default_ttl}
DEPLOYMENT_STAGE: ${self:custom.stage}
apiGateway:
apiKeys:
- name: SOLVIS_GRAPHQL_API_TempApiKey-${self:custom.stage}
description: Api key until we have an auth function # Optional
iam:
role:
statements:
# Cloudwatch
- Effect: Allow
Action:
- "cloudwatch:PutMetricData"
Resource: "*"
# S3 access policy
- Effect: Allow
Action:
- "s3:*"
Resource:
- ${self:custom.s3_role_resource}
- ${self:custom.s3_role_resource}/*
# DynamoDB
- Effect: Allow
Action:
- "dynamodb:Scan"
- "dynamodb:Query"
- "dynamodb:DescribeTable"
- "dynamodb:CreateTable"
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:ConditionCheckItem"
- "dynamodb:UpdateItem"
Resource: '*'
# ECR
- Effect: Allow
Action:
- ecr:GetDownloadUrlForLayer
- ecr:BatchGetImage
Resource:
- "arn:aws:ecr:*:461564345538:repository/*"
functions:
ecr-app:
description: The graphql API of ${self:service} as ECR container
# handler: wsgi_handler.handler
image:
name: app_image_0
command:
- solvis_graphql_api.handler.handler
entryPoint:
- '/lambda-entrypoint.sh'
memorySize: 2096 # optional, in MB, default is 1024
timeout: 20 # optional, in seconds, default is 6
events:
- http:
path: /{any+}
method: OPTIONS
- http:
path: /{any+}
method: POST
private: true
- http:
path: /{any+}
method: GET
private: true
environment:
SERVICE_NAME: ${self:service}
STACK_NAME: ${self:custom.stack_name}
REGION: ${self:custom.region}
DEPLOYMENT_STAGE: ${self:custom.stage}
ENABLE_METRICS: ${env:ENABLE_METRICS, 0}
LOGGING_CFG: ${env:LOGGING_CFG, "solvis_graphql_api/logging_aws.yaml"}
warmup:
littleWarmer:
enabled:
- test
- prod
- dev
resources:
Resources:
TheBlobBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.s3_bucket}