-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
254 lines (249 loc) · 11.3 KB
/
template.yaml
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md
# Indentation needs to be set with spaces, because YAML...
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Build constructed stats
Resources:
BuildHourlyConstructedDeckStats:
Type: AWS::Serverless::Function
Properties:
Handler: hourly/build-constructed-deck-stats.default
Runtime: nodejs18.x
Timeout: 880
CodeUri: ./dist/hourly/build-constructed-deck-stats
MemorySize: 6000
ReservedConcurrentExecutions: 5
VpcConfig:
SecurityGroupIds:
- sg-eccd2691
SubnetIds:
- subnet-894624ec # Only the private subnet
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- AmazonSESFullAccess
- SecretsManagerReadWrite
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# For VPC
- AWSLambdaENIManagementAccess
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: cron-build-hourly-constructed-deck-stats
Events:
# Populate the info on the last hour
LastPeriodTrigger:
Type: Schedule
Properties:
# Cron that runs every hour at 10 minutes past the hour
Schedule: cron(10 * * * ? *)
BuildDailyAggregateDeckStats:
Type: AWS::Serverless::Function
Properties:
Handler: daily/_build-daily-aggregate.default
Runtime: nodejs18.x
Timeout: 880
CodeUri: ./dist/daily/_build-daily-aggregate
MemorySize: 8000
ReservedConcurrentExecutions: 10
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- AmazonSESFullAccess
- SecretsManagerReadWrite
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: cron-build-daily-aggregate-deck-stats
Events:
# Populate the info on the last hour
LastPeriodTrigger:
Type: Schedule
Properties:
# Cron that runs once a day at 00:10
Schedule: cron(10 0 * * ? *)
FinalStatsByClass:
Type: AWS::Serverless::Function
Properties:
Handler: final-result-by-class/build-aggregated-stats.default
Runtime: nodejs18.x
Timeout: 800
CodeUri: ./dist/final-result-by-class/build-aggregated-stats
MemorySize: 10000
ReservedConcurrentExecutions: 10 # Need to investigate locks. To avoid lock races when inserting data in DB
VpcConfig:
SecurityGroupIds:
- sg-eccd2691
SubnetIds:
- subnet-894624ec # Only the private subnet
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- SecretsManagerReadWrite
- AmazonSESFullAccess
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# For VPC
- AWSLambdaENIManagementAccess
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: cron-constructed-final-stats-by-class
# TODO: trigger this after the hourly builds have been done, either via direct lambda invocation
# or via sqs
Events:
LastPeriodTrigger:
Type: Schedule
Properties:
# Cron that runs every hour at 40 minutes past the hour
# Schedule: cron(25 * * * ? *)
Schedule: cron(25 0/3 * * ? *)
FinalStatsByClassVersion:
Type: AWS::Lambda::Version
Properties:
FunctionName: !Ref FinalStatsByClass
FinalStatsByClassAsyncConfig:
Type: AWS::Lambda::EventInvokeConfig
Properties:
FunctionName: !Ref FinalStatsByClass
MaximumRetryAttempts: 0
Qualifier: !GetAtt FinalStatsByClassVersion.Version
FinalStats:
Type: AWS::Serverless::Function
Properties:
Handler: final-stats/_build-aggregated-stats.default
Runtime: nodejs18.x
Timeout: 800
CodeUri: ./dist/final-stats/_build-aggregated-stats
MemorySize: 2000
ReservedConcurrentExecutions: 10 # Need to investigate locks. To avoid lock races when inserting data in DB
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- AmazonSESFullAccess
- SecretsManagerReadWrite
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: cron-constructed-final-stats
# TODO: trigger this after the hourly builds have been done, either via direct lambda invocation
# or via sqs
Events:
LastPeriodTrigger:
Type: Schedule
Properties:
# Cron that runs every hour at 40 minutes past the hour
# Schedule: cron(40 * * * ? *)
Schedule: cron(40 0/3 * * ? *)
FinalStatsVersion:
Type: AWS::Lambda::Version
Properties:
FunctionName: !Ref FinalStats
FinalStatsAsyncConfig:
Type: AWS::Lambda::EventInvokeConfig
Properties:
FunctionName: !Ref FinalStats
MaximumRetryAttempts: 0
Qualifier: !GetAtt FinalStatsVersion.Version
RetrieveConstructedDeckDetails:
Type: AWS::Serverless::Function
Properties:
Handler: retrieve/get-constructed-meta-deck.default
Runtime: nodejs18.x
Timeout: 15
MemorySize: 512
CodeUri: ./dist/retrieve/get-constructed-meta-deck
VpcConfig:
SecurityGroupIds:
- sg-eccd2691
SubnetIds:
- subnet-894624ec # Only the private subnet
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- AmazonSESFullAccess
- SecretsManagerReadWrite
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# For VPC
- AWSLambdaENIManagementAccess
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: api-get-constructed-meta-deck
AutoPublishAlias: live
FunctionUrlConfig:
AuthType: NONE
ApiGatewayRestApi:
Type: AWS::Serverless::Api
Cors:
AllowMethods: "'*'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
Properties:
Name: ConstructedDeckDetailsApi
StageName: prod
CacheClusterEnabled: true
CacheClusterSize: '1.6'
MethodSettings:
- HttpMethod: '*'
CacheTtlInSeconds: 3600
ResourcePath: "/*"
CachingEnabled: true
LoggingLevel: ERROR
RetrieveConstructedDeckDetailsViaApiGateway:
Type: AWS::Serverless::Function
Properties:
Handler: retrieve/get-constructed-meta-deck-api-gateway.default
Runtime: nodejs18.x
Timeout: 15
MemorySize: 600
CodeUri: ./dist/retrieve/get-constructed-meta-deck-api-gateway
# Layers:
# - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
Policies:
- AWSLambdaVPCAccessExecutionRole
- AmazonSESFullAccess
- SecretsManagerReadWrite
- AmazonSNSReadOnlyAccess
- AmazonS3FullAccess
- AWSLambda_FullAccess
- arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy
# - arn:aws:iam::478062583808:policy/CloudWatchPolicyForLambda # See https://stackoverflow.com/questions/51166504/disable-cloudwatch-to-monitor-logs-for-lambda-function
Tags:
LambdaName: api-get-constructed-meta-deck-api-gateway
Events:
ApiGateway:
Type: Api
Properties:
Path: /constructed-meta-deck
Method: GET
RestApiId: !Ref ApiGatewayRestApi
RequestParameters:
- method.request.querystring.format:
Required: true
Caching: true
- method.request.querystring.rank:
Required: true
Caching: true
- method.request.querystring.timePeriod:
Required: true
Caching: true
- method.request.querystring.deckId:
Required: true
Caching: true