forked from mlevit/aws-auto-cleanup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
210 lines (204 loc) · 5.67 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
service: auto-cleanup-api
custom:
log_level: INFO # DEBUG for dev | INFO for prod
region: ${opt:region, "ap-southeast-2"} # AWS deployment region
apiGatewayCaching:
enabled: true
manifest:
output: ../web/src/serverless.manifest.json
silent: true
pythonRequirements:
layer:
name: ${self:service}-${self:provider.stage}-requirements
compatibleRuntimes:
- python3.9
noDeploy:
- boto
- boto3
- botocore
slim: true
provider:
name: aws
runtime: python3.9
stage: ${opt:stage, "prod"} # overwrite via CLI "--stage dev"
region: ${self:custom.region}
apiGateway:
apiKeys:
- ${self:service}-${self:provider.stage}-api-key
minimumCompressionSize: 0
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:DeleteItem
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:Scan
Resource: "*"
- Effect: Allow
Action:
- s3:Get*
- s3:List*
Resource: "*"
tracing:
apiGateway: true
lambda: true
package:
individually: true
patterns:
- "!node_modules/**"
functions:
AllowlistCreate:
handler: src/allowlist/create.lambda_handler
name: ${self:service}-${self:provider.stage}-allowlist-create
description: Create allowlist entry
memorySize: 128
timeout: 30
package:
patterns:
- "!**"
- "src/allowlist/create.py"
environment:
LOG_LEVEL: ${self:custom.log_level}
SETTINGS_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.SettingsTableName}
ALLOWLIST_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.AllowlistTableName}
layers:
- Ref: PythonRequirementsLambdaLayer
events:
- http:
method: POST
path: /allowlist/entry
cors: true
private: true
AllowlistRead:
handler: src/allowlist/read.lambda_handler
name: ${self:service}-${self:provider.stage}-allowlist-read
description: Read allowlist
memorySize: 512
timeout: 30
package:
patterns:
- "!**"
- "src/allowlist/read.py"
environment:
LOG_LEVEL: ${self:custom.log_level}
ALLOWLIST_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.AllowlistTableName}
events:
- http:
method: GET
path: /allowlist
cors: true
private: true
AllowlistUpdate:
handler: src/allowlist/update.lambda_handler
name: ${self:service}-${self:provider.stage}-allowlist-update
description: Update allowlist entry
memorySize: 128
timeout: 30
package:
patterns:
- "!**"
- "src/allowlist/update.py"
layers:
- Ref: PythonRequirementsLambdaLayer
environment:
LOG_LEVEL: ${self:custom.log_level}
SETTINGS_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.SettingsTableName}
ALLOWLIST_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.AllowlistTableName}
events:
- http:
method: PUT
path: /allowlist/entry
cors: true
private: true
AllowlistDelete:
handler: src/allowlist/delete.lambda_handler
name: ${self:service}-${self:provider.stage}-allowlist-delete
description: Delete allowlist entry
memorySize: 128
timeout: 30
package:
patterns:
- "!**"
- "src/allowlist/delete.py"
environment:
LOG_LEVEL: ${self:custom.log_level}
ALLOWLIST_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.AllowlistTableName}
events:
- http:
method: DELETE
path: /allowlist/entry
cors: true
private: true
ServiceRead:
handler: src/service/read.lambda_handler
name: ${self:service}-${self:provider.stage}-service-read
description: Returns AWS services supported by Auto Cleanup
memorySize: 512
timeout: 30
package:
patterns:
- "!**"
- "src/service/read.py"
layers:
- Ref: PythonRequirementsLambdaLayer
environment:
LOG_LEVEL: ${self:custom.log_level}
SETTINGS_TABLE: ${cf:auto-cleanup-app-${self:provider.stage}.SettingsTableName}
events:
- http:
method: GET
path: /settings/service
cors: true
private: true
ExecutionLogList:
handler: src/execution_log/list.lambda_handler
name: ${self:service}-${self:provider.stage}-execution-log-list
description: Returns execution logs
memorySize: 512
timeout: 30
package:
patterns:
- "!**"
- "src/execution_log/list.py"
environment:
LOG_LEVEL: ${self:custom.log_level}
EXECUTION_LOG_BUCKET: ${cf:auto-cleanup-app-${self:provider.stage}.ExecutionLogBucketName}
events:
- http:
method: GET
path: /execution
cors: true
private: true
ExecutionLogRead:
handler: src/execution_log/read.lambda_handler
name: ${self:service}-${self:provider.stage}-execution-log-read
description: Returns execution logs
memorySize: 2048
timeout: 30
package:
patterns:
- "!**"
- "src/execution_log/read.py"
environment:
LOG_LEVEL: ${self:custom.log_level}
EXECUTION_LOG_BUCKET: ${cf:auto-cleanup-app-${self:provider.stage}.ExecutionLogBucketName}
events:
- http:
method: GET
path: /execution/{key}
cors: true
private: true
caching:
enabled: false
# cacheKeyParameters:
# - name: request.path.key
resources:
Outputs:
AccountID:
Value: !Ref AWS::AccountId
plugins:
- serverless-api-gateway-caching
- serverless-manifest-plugin
- serverless-python-requirements