-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
195 lines (183 loc) · 6.06 KB
/
serverless.yml
File metadata and controls
195 lines (183 loc) · 6.06 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
service: abstract-play-backend-crons
frameworkVersion: "3"
custom:
scheduleEnabled:
prod: true
dev: false
recbucket:
prod: "records.abstractplay.com"
dev: "records.abstractplay.com"
dumpbucket: "abstractplay-db-dump"
esbuild:
tsconfig: "./tsconfig.json"
bundle: true
sourcemap: false # Sourcemaps are large and not needed in production
format: "esm"
outExtension:
".js": ".mjs"
platform: "node"
target: "node20"
external:
- "@abstractplay/gameslib"
- "@abstractplay/recranks"
- "@aws-sdk/*"
- "@smithy/*"
- "buffer"
- "fs"
exclude:
- "@abstractplay/gameslib"
- "@abstractplay/recranks"
scriptable:
hooks:
before:package:createDeploymentArtifacts: npm run build:layers
params:
dev:
profile: AbstractPlayDev
prod:
profile: AbstractPlayProd
plugins:
- serverless-esbuild
- serverless-scriptable-plugin
provider:
name: aws
runtime: nodejs20.x
versionFunctions: false
stage: ${opt:stage, "dev"}
profile: ${param:profile}
region: us-east-1
memorySize: 1024
logs:
retentionInDays: 30 # set to any valid retention period (1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653)
environment:
ABSTRACT_PLAY_TABLE: abstract-play-${self:provider.stage}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:ExportTableToPointInTime
- dynamodb:BatchWriteItem
- sqs:SendMessage
- ses:SendEmail
- ses:SendRawEmail
- cloudfront:CreateInvalidation
Resource: "*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource:
- "arn:aws:s3:::abstractplay-db-dump"
- "arn:aws:s3:::records.abstractplay.com"
- Effect: "Allow"
Action:
- "s3:GetObject"
Resource:
- "arn:aws:s3:::abstractplay-db-dump/*"
- Effect: "Allow"
Action:
- "s3:PutObject"
Resource:
- "arn:aws:s3:::records.abstractplay.com/*"
- "arn:aws:s3:::thumbnails.abstractplay.com/*"
- "arn:aws:s3:::abstractplay-db-dump/*"
functions:
dumpdb:
handler: src/functions/dumpdb.handler
description: Triggers a full export of production DB to S3
logRetentionInDays: 30
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-dumpdb
description: Triggers a full export of production DB to S3
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# midnight UTC every Sunday
schedule: cron(0 0 * * ? *)
records:
handler: src/functions/records.handler
description: Generates static lists of game records
timeout: 900
memorySize: 10240
logRetentionInDays: 30
layers:
- !Ref AbstractplayGameslibLambdaLayer
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-records
description: Generates static lists of game records
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# 3am UTC every sunday (giving the dump plenty of time to complete)
schedule: cron(0 3 * * ? *)
records-ttm:
handler: src/functions/records-ttm.handler
description: Generates static time-to-move results of each game
timeout: 900
memorySize: 10240
logRetentionInDays: 30
layers:
- !Ref AbstractplayGameslibLambdaLayer
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-records-ttm
description: Generates static time-to-move results of each game
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# 3am UTC every sunday (giving the dump plenty of time to complete)
schedule: cron(0 3 * * ? *)
records-move-times:
handler: src/functions/records-move-times.handler
description: Generates list of moves made in past 180 days
timeout: 900
memorySize: 10240
logRetentionInDays: 30
layers:
- !Ref AbstractplayGameslibLambdaLayer
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-records-move-times
description: Generates list of moves made in past 180 days
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# 3am UTC every sunday (giving the dump plenty of time to complete)
schedule: cron(0 3 * * ? *)
records-manifest:
handler: src/functions/records-manifest.handler
description: Generates manifest file for records bucket
timeout: 900
memorySize: 10240
logRetentionInDays: 30
layers:
- !Ref AbstractplayGameslibLambdaLayer
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-records-manifest
description: Generates static time-to-move results of each game
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# 4am UTC every sunday (giving the various records scripts time to complete)
# then run again after summarize
schedule: cron(0 4,7 * * ? *)
summarize:
handler: src/functions/summarize.handler
description: Summarize generated game reports
timeout: 120
layers:
- !Ref AbstractplayGameslibLambdaLayer
logRetentionInDays: 30
events:
- eventBridge:
name: abstractplay-${self:provider.stage}-summarize
description: Summarize generated game reports
enabled: ${self:custom.scheduleEnabled.${self:provider.stage}}
# 6am UTC daily (giving plenty of time for the record generation to complete)
schedule: cron(0 6 * * ? *)
layers:
abstractplayGameslib:
path: .serverless/layers/abstractplay-gameslib
name: abstractplay-gameslib-${sls:stage}
description: "Layer for @abstractplay/gameslib"
compatibleRuntimes:
- nodejs20.x
retain: false