-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
500 lines (497 loc) · 14.6 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
solace-stats
API for statistics on the Solace Coverage Protocol
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
AutoPublishAlias: live
Tracing: Active
Environment:
Variables:
DEAD_LETTER_TOPIC: arn:aws:sns:us-west-2:151427405638:DeadLetterSnsTopic
DATA_BUCKET: stats.solace.fi.data
DeadLetterQueue:
Type: SNS
TargetArn: arn:aws:sns:us-west-2:151427405638:DeadLetterSnsTopic
Api:
Cors:
AllowMethods: "'OPTIONS,GET,POST,PUT,DELETE'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
Resources:
# Rest API
RestApi:
Type: AWS::Serverless::Api
Properties:
Name: SolaceStatsApi
Domain:
DomainName: stats.solace.fi
CertificateArn: arn:aws:acm:us-west-2:151427405638:certificate/55b18704-e0db-4ce8-b070-43fc8b0c919d
Route53:
HostedZoneId: Z0480029MZJJGNMS3NEJ
StageName: prod
TracingEnabled: true
OptionsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsOptionsFunction
Handler: api/options.handler
Runtime: nodejs14.x
MemorySize: 128
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /
Method: options
RestApiId: !Ref RestApi
FaviconFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsFaviconFunction
Handler: api/favicon/get.handler
Runtime: nodejs14.x
MemorySize: 128
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /favicon.ico
Method: get
RestApiId: !Ref RestApi
IndexFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsIndexFunction
Handler: api/get.handler
Runtime: nodejs14.x
MemorySize: 128
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /
Method: get
RestApiId: !Ref RestApi
SolaceBalanceOfFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsSolaceBalanceOfFunction
Handler: api/SOLACE/balanceOf/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /SOLACE/balanceOf
Method: get
RestApiId: !Ref RestApi
SolaceTotalSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsSolaceTotalSupplyFunction
Handler: api/SOLACE/totalSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /SOLACE/totalSupply
Method: get
RestApiId: !Ref RestApi
SolaceCirculatingSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsSolaceCirculatingSupplyFunction
Handler: api/SOLACE/circulatingSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /SOLACE/circulatingSupply
Method: get
RestApiId: !Ref RestApi
XSolaceBalanceOfFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceBalanceOfFunction
Handler: api/xSOLACE/balanceOf/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACE/balanceOf
Method: get
RestApiId: !Ref RestApi
XSolaceTotalSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceTotalSupplyFunction
Handler: api/xSOLACE/totalSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACE/totalSupply
Method: get
RestApiId: !Ref RestApi
XSolaceCirculatingSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceCirculatingSupplyFunction
Handler: api/xSOLACE/circulatingSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACE/circulatingSupply
Method: get
RestApiId: !Ref RestApi
XSLockerGetFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSLockerGetFunction
Handler: api/xsLocker/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xsLocker
Method: get
RestApiId: !Ref RestApi
VotePowerFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsVotePowerFunction
Handler: api/votePower/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /votePower
Method: get
RestApiId: !Ref RestApi
XSolaceV1BalanceOfFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceV1BalanceOfFunction
Handler: api/xSOLACEv1/balanceOf/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACEv1/balanceOf
Method: get
RestApiId: !Ref RestApi
XSolaceV1TotalSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceV1TotalSupplyFunction
Handler: api/xSOLACEv1/totalSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACEv1/totalSupply
Method: get
RestApiId: !Ref RestApi
XSolaceV1CirculatingSupplyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsXSolaceV1CirculatingSupplyFunction
Handler: api/xSOLACEv1/circulatingSupply/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /xSOLACEv1/circulatingSupply
Method: get
RestApiId: !Ref RestApi
SoteriaPolicyDescriptorFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsSoteriaPolicyDescriptorFunction
Handler: api/policy/get.handler
Runtime: python3.8
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /policy
Method: get
RestApiId: !Ref RestApi
SolaceTVLFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsTVLFunction
Handler: api/tvl/get.handler
Runtime: python3.8
MemorySize: 1024
Timeout: 600
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /tvl
Method: get
RestApiId: !Ref RestApi
SolaceTVLCalculatorFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsTVLCalculatorFunction
Handler: api/tvl/tvl_calculator.main
Runtime: python3.8
MemorySize: 1024
Timeout: 600
Role: !GetAtt LambdaExecutionRole.Arn
Events:
ScheduledEvent:
Type: Schedule
Properties:
Schedule: rate(60 minutes)
SolaceStatsTrackerFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsTrackerFunction
Handler: api/tracker.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 900
Role: !GetAtt LambdaExecutionRole.Arn
Events:
ScheduledEvent:
Type: Schedule
Properties:
Schedule: rate(60 minutes)
FsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsFsFunction
Handler: api/fs/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 60
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /fs
Method: get
RestApiId: !Ref RestApi
Erc20HoldersFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: SolaceStatsErc20HoldersFunction
Handler: api/erc20holders/get.handler
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 900
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /erc20holders
Method: get
RestApiId: !Ref RestApi
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: SolaceStatsLambdaExecutionRole
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [lambda.amazonaws.com]
Action: sts:AssumeRole
Path: /
ManagedPolicyArns:
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
Policies:
- PolicyName: SolaceStatsLambdaExecutionPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sns:Publish"
Resource: "arn:aws:sns:us-west-2:151427405638:DeadLetterSnsTopic"
- Effect: Allow
Action:
- "s3:GetObject"
- "s3:DeleteObject"
- "s3:ListBucket"
- "s3:PutObject"
- "s3:ReplicateObject"
- "s3:RestoreObject"
Resource: "arn:aws:s3:::stats.solace.fi.data/*"
# Data Bucket
DataBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: stats.solace.fi.data
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
CorsConfiguration:
CorsRules:
- AllowedMethods:
- HEAD
- GET
AllowedOrigins:
- "*"
AllowedHeaders:
- "*"
# begin stats-cache.solace.fi bucket and distribution
StatsCacheWebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: stats-cache.solace.fi
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
CorsConfiguration:
CorsRules:
- AllowedMethods:
- HEAD
- GET
AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
WebsiteConfiguration:
IndexDocument: index.html
Tags:
- Key: Project
Value: client
StatsCacheWebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref StatsCacheWebsiteBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Action:
- "s3:GetObject"
Effect: "Allow"
Resource: arn:aws:s3:::stats-cache.solace.fi/*
Principal:
AWS: !Join ["", ["arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ", "EPMQ7FUHPT5YX"] ]
StatsCacheWebsiteDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
- Id: StatsCacheWebsiteBucket
DomainName: stats-cache.solace.fi.s3.amazonaws.com
S3OriginConfig:
OriginAccessIdentity: !Join ["", ["origin-access-identity/cloudfront/", "EPMQ7FUHPT5YX"] ]
Enabled: 'true'
Aliases:
- stats-cache.solace.fi
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
CachedMethods:
- GET
- HEAD
- OPTIONS
Compress: true
ViewerProtocolPolicy: redirect-to-https
TargetOriginId: StatsCacheWebsiteBucket
CachePolicyId: "4135ea2d-6df8-44a3-9df3-4b5a84be39ad"
OriginRequestPolicyId: "88a5eaf4-2fd4-4709-b370-b4c650ea3fcf"
ResponseHeadersPolicyId: "5cc3b908-e619-4b99-88e5-2cf7f45965bd"
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:151427405638:certificate/54ea004e-a3bf-4f9e-a027-d9f4f0dc2d34
MinimumProtocolVersion: TLSv1.2_2018
SslSupportMethod: sni-only
HttpVersion: http2
IPV6Enabled: true
Tags:
- Key: Project
Value: client
DependsOn: StatsCacheWebsiteBucketPolicy
StatsCacheDnsZoneIPv4:
Type: AWS::Route53::RecordSet
Properties:
AliasTarget:
DNSName: !GetAtt StatsCacheWebsiteDistribution.DomainName
EvaluateTargetHealth: false
HostedZoneId: Z2FDTNDATAQYW2
HostedZoneName: solace.fi.
Name: stats-cache.solace.fi
Type: A
DependsOn: StatsCacheWebsiteDistribution
StatsCacheDnsZoneIPv6:
Type: AWS::Route53::RecordSet
Properties:
AliasTarget:
DNSName: !GetAtt StatsCacheWebsiteDistribution.DomainName
EvaluateTargetHealth: false
HostedZoneId: Z2FDTNDATAQYW2
HostedZoneName: solace.fi.
Name: stats-cache.solace.fi
Type: AAAA
DependsOn: StatsCacheWebsiteDistribution
# end stats-cache.solace.fi bucket and distribution