-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserverless.yml
850 lines (811 loc) · 24.1 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
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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
# Welcome to serverless. Read the docs
# https://serverless.com/framework/docs/
# Serverless.yml is the configuration the CLI
# uses to deploy your code to your provider of choice
# The `service` block is the name of the service
service: hathor-explorer-service
useDotenv: true
# The `provider` block defines where your service will be deployed
provider:
name: aws
# WARN: If you change this, make sure you also change the `Dockerfile_Serverless` base image to match the python version
runtime: "python3.9"
region: ${env:AWS_DEFAULT_REGION}
lambdaHashingVersion: 20201221
stackTags:
Application: "hathor-explorer-service"
Stage: "${self:custom.stage}"
apiGateway:
apiKeys:
- explorer-service-${self:custom.stage}-healthcheck-api-key
logs:
restApi: # TODO: add data to make the serverless create this role by itself
role: arn:aws:iam::${env:AWS_ACCOUNT_ID}:role/APIGatewayPushLogsToCloudWatch
vpc:
securityGroupIds:
- ${env:AWS_VPC_DEFAULT_SG_ID}
subnetIds:
- ${env:AWS_SUBNET_ID_1}
- ${env:AWS_SUBNET_ID_2}
- ${env:AWS_SUBNET_ID_3}
environment:
HATHOR_CORE_URL: ${env:HATHOR_CORE_URL}
HATHOR_NODES: ${env:HATHOR_NODES}
REDIS_KEY_PREFIX: ${env:REDIS_KEY_PREFIX}
REDIS_HOST: ${env:REDIS_HOST}
REDIS_PORT: ${env:REDIS_PORT}
REDIS_DB: ${env:REDIS_DB}
METADATA_BUCKET: ${env:METADATA_BUCKET}
CORS_ALLOWED_REGEX: ${env:CORS_ALLOWED_REGEX}
NODE_CACHE_TTL: ${env:NODE_CACHE_TTL}
ELASTIC_CLOUD_ID: ${env:ELASTIC_CLOUD_ID}
ELASTIC_USER: ${env:ELASTIC_USER}
ELASTIC_PASSWORD: ${env:ELASTIC_PASSWORD}
ELASTIC_INDEX: ${env:ELASTIC_INDEX}
ELASTIC_TOKEN_BALANCES_INDEX: ${env:ELASTIC_TOKEN_BALANCES_INDEX}
ELASTIC_RESULTS_PER_PAGE: ${env:ELASTIC_RESULTS_PER_PAGE}
ELASTIC_SEARCH_TIMEOUT: ${env:ELASTIC_SEARCH_TIMEOUT}
ELASTIC_TX_INDEX: ${env:ELASTIC_TX_INDEX}
WALLET_SERVICE_DB_USERNAME: ${env:WALLET_SERVICE_DB_USERNAME}
WALLET_SERVICE_DB_PASSWORD: ${env:WALLET_SERVICE_DB_PASSWORD}
WALLET_SERVICE_DB_HOST: ${env:WALLET_SERVICE_DB_HOST}
WALLET_SERVICE_DB_NAME: ${env:WALLET_SERVICE_DB_NAME}
HEALTHCHECK_HATHOR_CORE_ENABLED: ${env:HEALTHCHECK_HATHOR_CORE_ENABLED}
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED: ${env:HEALTHCHECK_WALLET_SERVICE_DB_ENABLED}
HEALTHCHECK_ELASTICSEARCH_ENABLED: ${env:HEALTHCHECK_ELASTICSEARCH_ENABLED}
HEALTHCHECK_REDIS_ENABLED: ${env:HEALTHCHECK_REDIS_ENABLED}
plugins:
- serverless-better-credentials
- serverless-s3-local
- serverless-offline
- serverless-python-requirements
- serverless-api-gateway-caching
- serverless-plugin-aws-alerts
- serverless-api-gateway-throttling
package:
individually: true
patterns:
- '!*'
- '!**/*'
- 'common/**'
- 'domain/**'
- 'gateways/**'
- 'usecases/**'
- 'utils/**'
- '!**/__pycache__'
custom:
stage: ${opt:stage, 'dev'}
serverless-offline:
httpPort: ${env:API_PORT}
host: 0.0.0.0
pythonRequirements:
layer: true
pythonBin: python3
dockerizePip: true
dockerFile: ./Dockerfile_Serverless
useStaticCache: false
useDownloadCache: false
s3:
host: localhost
directory: /tmp
buckets: ${env:METADATA_BUCKET}
apiGatewayCaching:
enabled: true
ttlInSeconds: 300
apiGatewayThrottling:
# Apply to all http endpoints, unless overridden
# According to AWS: "Each method in this stage will respect these rate and burst settings."
maxRequestsPerSecond: 50
maxConcurrentRequests: 25
alerts:
stages: # Select which stages to deploy alarms to
- mainnet
- testnet
topics: # SNS Topics to send alerts to
major:
alarm:
topic: arn:aws:sns:${self:provider.region}:${env:AWS_ACCOUNT_ID}:opsgenie-cloudwatch-integration-production-major
medium:
alarm:
topic: arn:aws:sns:${self:provider.region}:${env:AWS_ACCOUNT_ID}:opsgenie-cloudwatch-integration-production-medium
minor:
alarm:
topic: arn:aws:sns:${self:provider.region}:${env:AWS_ACCOUNT_ID}:opsgenie-cloudwatch-integration-production-minor
definitions: # Definition of alarms
majorFunctionErrors:
description: "More than 10 errors in the Lambda for 3 consecutive minutes. Runbook: https://github.com/HathorNetwork/ops-tools/blob/master/docs/runbooks/hathor-explorer-service/errors-in-lambdas.md"
namespace: 'AWS/Lambda'
metric: Errors
threshold: 10
statistic: Sum
period: 60
evaluationPeriods: 3
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: notBreaching
alarmActions:
- major
mediumFunctionErrors:
description: "More than 3 errors in the Lambda for 3 consecutive minutes. Runbook: https://github.com/HathorNetwork/ops-tools/blob/master/docs/runbooks/hathor-explorer-service/errors-in-lambdas.md"
namespace: 'AWS/Lambda'
metric: Errors
threshold: 3
statistic: Sum
period: 60
evaluationPeriods: 3
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: notBreaching
alarmActions:
- medium
minorFunctionErrors:
description: "More than 2 errors in the Lambda in 1 minute. Runbook: https://github.com/HathorNetwork/ops-tools/blob/master/docs/runbooks/hathor-explorer-service/errors-in-lambdas.md"
namespace: 'AWS/Lambda'
metric: Errors
threshold: 2
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: notBreaching
alarmActions:
- minor
alarms: # Alarms that will be applied to all functions
- majorFunctionErrors
- mediumFunctionErrors
- minorFunctionErrors
functions:
get_node_handler:
handler: handlers/get_node_handler.handle
package:
patterns:
- 'handlers/get_node_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node/{hash}
method: get
cors: true
request:
parameters:
paths:
hash: true
list_nodes_handler:
handler: handlers/list_nodes_handler.handle
package:
patterns:
- 'handlers/list_nodes_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node/
method: get
cors: true
get_network_handler:
handler: handlers/get_network_handler.handle
package:
patterns:
- 'handlers/get_network_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: network/
method: get
cors: true
node_data_aggregator_handler:
handler: handlers/node_data_aggregator.handle
timeout: 30
package:
patterns:
- 'handlers/node_data_aggregator.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
get_token_handler:
handler: handlers/get_token_handler.handle
package:
patterns:
- 'handlers/get_token_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: token/{hash}
method: get
cors: true
request:
parameters:
paths:
hash: true
caching:
enabled: true
ttlInSeconds: 15
cacheKeyParameters:
- name: request.path.hash
- name: request.header.origin
get_tokenbalances_handler:
handler: handlers/token_balance_api.get_token_balances
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/token_balance_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: token_balances
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.token_id
- name: request.querystring.sort_by
- name: request.querystring.order
- name: request.querystring.search_after
- name: request.header.origin
get_tokenbalance_info_handler:
handler: handlers/token_balance_api.get_token_information
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/token_balance_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: token_balances/information
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.token_id
get_tokens_handler:
handler: handlers/token_api.get_tokens
timeout: 15
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/token_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: tokens
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.search_text
- name: request.querystring.sort_by
- name: request.querystring.order
- name: request.querystring.search_after
- name: request.header.origin
# This get_token will get tokens from the elasticsearch index
es_get_token_handler:
handler: handlers/token_api.get_token
timeout: 15
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/token_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: tokens/{token_id}
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.header.origin
- name: request.path.token_id
get_best_chain_height:
handler: handlers/block_api.get_best_chain_height
timeout: 30
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/block_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: blocks/best_chain_height
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 60
cacheKeyParameters:
- name: request.header.origin
get_dag_metadata_handler:
handler: handlers/dag_metadata_handler.handle_get
package:
patterns:
- 'handlers/dag_metadata_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: metadata/dag
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.id
- name: request.header.origin
create_or_update_dag_metadata:
handler: handlers/dag_metadata_handler.handle_create_or_update
package:
patterns:
- 'handlers/dag_metadata_handler.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
node_api_get_address_balance:
handler: handlers/node_api.get_address_balance
timeout: 15
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/address_balance
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.address
- name: request.header.origin
node_api_get_address_search:
handler: handlers/node_api.get_address_search
timeout: 15
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/address_search
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.address
- name: request.querystring.count
- name: request.querystring.token
- name: request.querystring.page
- name: request.querystring.hash
- name: request.header.origin
node_api_get_version:
handler: handlers/node_api.get_version
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/version
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 3600
cacheKeyParameters:
- name: request.header.origin
node_api_get_dashboard_tx:
handler: handlers/node_api.get_dashboard_tx
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/dashboard_tx
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.block
- name: request.querystring.tx
- name: request.header.origin
node_api_get_tx_acc_w:
handler: handlers/node_api.get_transaction_acc_weight
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/transaction_acc_weight
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 5
cacheKeyParameters:
- name: request.querystring.id
- name: request.header.origin
node_api_get_token_history:
handler: handlers/node_api.get_token_history
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/token_history
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.id
- name: request.querystring.count
- name: request.querystring.hash
- name: request.querystring.page
- name: request.querystring.timestamp
- name: request.header.origin
node_api_get_transaction:
handler: handlers/node_api.get_transaction
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/transaction
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.id
- name: request.header.origin
node_api_get_feature:
handler: handlers/node_api.get_feature
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/feature
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.block
- name: request.header.origin
node_api_list_transactions:
handler: handlers/node_api.list_transactions
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/transactions
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.type
- name: request.querystring.count
- name: request.querystring.hash
- name: request.querystring.page
- name: request.querystring.timestamp
- name: request.header.origin
node_api_get_token:
handler: handlers/node_api.get_token
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/token
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.id
- name: request.header.origin
node_api_decode_tx:
handler: handlers/node_api.decode_tx
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/decode_tx
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.hex_tx
- name: request.header.origin
node_api_push_tx:
handler: handlers/node_api.push_tx
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/push_tx
method: post
cors: true
caching:
enabled: false
node_api_gviz_dot_neighbors:
handler: handlers/node_api.graphviz_dot_neighbors
timeout: 6
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/graphviz/neighbours.dot
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.tx
- name: request.querystring.graph_type
- name: request.querystring.max_level
- name: request.header.origin
# This API doesn't have cache because our plugin doesn't support
# multivalue caching. An issue was created to discuss this.
# https://github.com/HathorNetwork/hathor-explorer-service/issues/318
node_api_nc_state:
handler: handlers/node_api.nc_state
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/nc_state
method: get
cors: true
node_api_nc_history:
handler: handlers/node_api.nc_history
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/nc_history
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.id
- name: request.querystring.after
- name: request.querystring.before
- name: request.querystring.count
- name: request.header.origin
node_api_nc_blueprint_info:
handler: handlers/node_api.nc_blueprint_information
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/nc_blueprint_information
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.blueprint_id
- name: request.header.origin
node_api_nc_blueprint_code:
handler: handlers/node_api.nc_blueprint_source_code
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/node_api.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: node_api/nc_blueprint_source_code
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 300
cacheKeyParameters:
- name: request.querystring.blueprint_id
- name: request.header.origin
walletServiceAddressBalance:
handler: handlers/wallet_service.handle_address_balance
timeout: 15
package:
patterns:
- 'handlers/wallet_service.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: address/balance
method: get
cors: true
throttling:
maxRequestsPerSecond: 100
maxConcurrentRequests: 4
caching:
enabled: true
ttlInSeconds: 5
cacheKeyParameters:
- name: request.querystring.address
- name: request.querystring.token
- name: request.header.origin
walletServiceAddressHistory:
handler: handlers/wallet_service.handle_address_history
timeout: 15
package:
patterns:
- 'handlers/wallet_service.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: address/history
method: get
cors: true
throttling:
maxRequestsPerSecond: 100
maxConcurrentRequests: 4
caching:
enabled: true
ttlInSeconds: 5
cacheKeyParameters:
- name: request.querystring.address
- name: request.querystring.token
- name: request.querystring.limit
- name: request.querystring.last_tx
- name: request.querystring.last_ts
- name: request.header.origin
walletServiceAddressTokens:
handler: handlers/wallet_service.handle_address_tokens
timeout: 15
package:
patterns:
- 'handlers/wallet_service.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: address/tokens
method: get
cors: true
throttling:
maxRequestsPerSecond: 100
maxConcurrentRequests: 4
caching:
enabled: true
ttlInSeconds: 10
cacheKeyParameters:
- name: request.querystring.address
- name: request.querystring.limit
- name: request.querystring.offset
- name: request.header.origin
network_statistics_handler:
handler: handlers/network_statistics.get_basic_statistics
timeout: 5
maximumRetryAttempts: 0
package:
patterns:
- 'handlers/network_statistics.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: network-statistics
method: get
cors: true
caching:
enabled: true
ttlInSeconds: 60
perKeyInvalidation: # add invalidation policy
requireAuthorization: true
handleUnauthorizedRequests: Fail # fail if the request don't have the permission to invalidate the cache
healthcheck_handler:
handler: handlers/get_healthcheck.get_healthcheck
timeout: 15
package:
patterns:
- 'handlers/get_healthcheck.py'
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
private: true
path: health
method: get
cors: true
throttling:
maxRequestsPerSecond: 1
maxConcurrentRequests: 1