forked from DefiLlama/defillama-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
250 lines (244 loc) · 6.71 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
service: coins
package:
individually: true
provider:
name: aws
runtime: nodejs14.x
memorySize: 250
region: eu-central-1
endpointType: REGIONAL # Set to regional because the api gateway will be behind a cloudfront distribution
stage: prod # Default to dev if no stage is specified
tracing: # Enable X-Ray tracing (debugging)
apiGateway: true
lambda: true
iamRoleStatements:
- Effect: Allow # X-Ray permissions
Action:
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource: "*"
- Effect: "Allow"
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchGetItem
- dynamodb:BatchWriteItem
Resource:
- "Fn::GetAtt": [DynamoTable, Arn]
- Effect: "Allow"
Action:
- dynamodb:GetItem
Resource:
- "arn:aws:dynamodb:eu-central-1:856461987125:table/secrets"
- Effect: Allow # Lambda logs on cloudwatch
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- "Fn::Join":
- ":"
- - "arn:aws:logs"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "log-group:/aws/lambda/*:*:*"
# For warm-up functions
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource: "*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
- "s3:*Object*"
Resource: "*"
environment:
ETHEREUM_RPC: ${file(./env.js):ETHEREUM_RPC}
BSC_RPC: ${file(./env.js):BSC_RPC}
POLYGON_RPC: ${file(./env.js):POLYGON_RPC}
FANTOM_RPC: ${file(./env.js):FANTOM_RPC}
ARBITRUM_RPC: ${file(./env.js):ARBITRUM_RPC}
OPTIMISM_RPC: ${file(./env.js):OPTIMISM_RPC}
XDAI_RPC: ${file(./env.js):XDAI_RPC}
HARMONY_RPC: ${file(./env.js):HARMONY_RPC}
SOLANA_RPC: ${file(./env.js):SOLANA_RPC}
MISSING_COINS_DB_PWD: ${file(./env.js):MISSING_COINS_DB_PWD}
DEFILLAMA_SDK_MUTED: true
tableName: ${self:custom.tableName}
stage: ${self:custom.stage}
custom:
stage: ${opt:stage, self:provider.stage}
esbuild:
bundle: true
minify: false
concurrency: 4
prune:
automatic: true
number: 5 # Number of versions to keep
tableName: ${self:custom.stage}-coins-table
region: eu-central-1
domainMap:
prod:
domain: coins.llama.fi
certificateArn: "arn:aws:acm:us-east-1:856461987125:certificate/b4209013-30a6-417e-847e-6e630c3e77fe"
hostedZone: llama.fi
dev:
domain: staging-coins.llama.fi
certificateArn: "arn:aws:acm:us-east-1:856461987125:certificate/b4209013-30a6-417e-847e-6e630c3e77fe"
hostedZone: llama.fi
domain: ${self:custom.domainMap.${self:custom.stage}.domain}
certificateArn: ${self:custom.domainMap.${self:custom.stage}.certificateArn}
hostedZone: ${self:custom.domainMap.${self:custom.stage}.hostedZone}
logRetentionInDays: 30
functions:
fallback:
handler: src/fallback.default
events:
- http:
path: /{params+}
method: any
coins:
handler: src/getCoins.default
timeout: 60
events:
- http:
path: prices
method: post
mcaps:
handler: src/getMcaps.default
timeout: 60
events:
- http:
path: mcaps
method: post
chains:
handler: src/getChains.default
timeout: 60
events:
- http:
path: chains
method: get
coinPrices:
handler: src/getCoinPrices.default
timeout: 60
events:
- http:
path: coin/timestamps
method: post
currentCoinPrices:
handler: src/getCurrentCoins.default
timeout: 60
events:
- http:
path: prices/current/{coins}
method: get
coinFirstTimestamp:
handler: src/getCoinFirstTimestamp.default
timeout: 60
events:
- http:
path: prices/first/{coins}
method: get
historicalCoinPrices:
handler: src/getHistoricalCoins.default
timeout: 60
events:
- http:
path: prices/historical/{timestamp}/{coins}
method: get
coinPriceChart:
handler: src/getCoinPriceChart.default
timeout: 60
events:
- http:
path: chart/{coins}
method: get
batchHistorical:
handler: src/getBatchHistoricalCoins.default
timeout: 60
events:
- http:
path: batchHistorical
method: get
coinPercentageChange:
handler: src/getPercentageChange.default
timeout: 60
events:
- http:
path: percentage/{coins}
method: get
block:
handler: src/getBlock.default
timeout: 60
events:
- http:
path: block/{chain}/{timestamp}
method: get
environment:
LLAMA_PROVIDER_RPC_GET_BLOCKNUMBER_TIMEOUT: 3000
corsPreflight:
handler: src/corsPreflight.default
events:
- http:
path: /{params+}
method: options
# fetchCoingeckoData2:
# handler: src/fetchCoingeckoData.fetchCoingeckoData
# timeout: 900
# environment:
# CG_KEY: ${env:CG_KEY}
# triggerFetchCoingeckoData:
# handler: src/triggerFetchCoingeckoData.triggerNewFetches
# events:
# - schedule: rate(5 minutes)
# environment:
# CG_KEY: ${env:CG_KEY}
# triggerHourlyFetchCoingeckoData:
# handler: src/triggerFetchCoingeckoData.triggerHourlyFetches
# events:
# - schedule: cron(0 0,12 * * ? *) # every 12 hours
# environment:
# CG_KEY: ${env:CG_KEY}
# fetchHourlyCoingeckoData:
# handler: src/fetchCoingeckoData.fetchHourlyCoingeckoData
# timeout: 900
# environment:
# CG_KEY: ${env:CG_KEY}
# storeDefiCoins:
# handler: src/storeCoins.default
# timeout: 900
# memorySize: 1024
# environment:
# STALE_COINS_ADAPTERS_WEBHOOK: ${env:STALE_COINS_ADAPTERS_WEBHOOK}
# triggerStoreDefiCoins:
# handler: src/triggerStoreCoins.default
# timeout: 900
# events:
# - schedule: cron(45 * * * ? *) # Hourly
StoreBridgedCoins:
handler: src/storeBridgedCoins.default
timeout: 900
memorySize: 1024
events:
- schedule: cron(45 * * * ? *) # Hourly
environment:
R2_ACCESS_KEY_ID: ${env:R2_ACCESS_KEY_ID}
R2_SECRET_ACCESS_KEY: ${env:R2_SECRET_ACCESS_KEY}
R2_ENDPOINT: ${env:R2_ENDPOINT}
resources:
# CORS for api gateway errors
- ${file(resources/api-gateway-errors.yml)}
# DynamoDB
- ${file(resources/dynamodb-table.yml)}
# Cloudfront API distribution
- ${file(resources/api-cloudfront-distribution.yml)}
plugins:
- serverless-esbuild
- serverless-offline
- serverless-prune-plugin
- serverless-plugin-log-retention