-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathserverless.yml
More file actions
149 lines (143 loc) · 3.73 KB
/
Copy pathserverless.yml
File metadata and controls
149 lines (143 loc) · 3.73 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
service: defillama
package:
individually: true
provider:
name: aws
runtime: nodejs14.x
region: eu-central-1
endpointType: REGIONAL # Set to regional because the api gateway will be behind a cloudfront distribution
stage: dev # 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
Resource:
- "Fn::GetAtt": [ DynamoTable, Arn ]
- 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: '*'
environment:
ALCHEMY_API: ${file(./env.js):ALCHEMY_API}
DEFILLAMA_SDK_MUTED: true
tableName: ${self:custom.tableName}
stage: ${self:custom.stage}
custom:
stage: ${opt:stage, self:provider.stage}
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
packager: 'npm'
excludeFiles: src/**/*.test.ts
warmup:
enabled: true
events:
- schedule: rate(5 minutes)
prewarm: true
concurrency: 1
prune:
automatic: true
number: 5 # Number of versions to keep
tableName: ${self:custom.stage}-table
domainMap:
prod:
domain: api.llama.fi
certificateArn: 'arn:aws:acm:us-east-1:856461987125:certificate/b4209013-30a6-417e-847e-6e630c3e77fe'
hostedZone: llama.fi
dev:
domain: staging-api.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}
functions:
fallback:
handler: src/fallback.default
events:
- http:
path: /{params+}
method: any
chart:
handler: src/getChart.default
warmup:
enabled: true
events:
- http:
path: charts
method: get
- http:
path: charts/{chain}
method: get
protocols:
handler: src/getProtocols.default
warmup:
enabled: true
events:
- http:
path: protocols
method: get
protocol:
handler: src/getProtocol.default
events:
- http:
path: protocol/{protocol}
method: get
corsPreflight:
handler: src/corsPreflight.default
warmup:
enabled: true
events:
- http:
path: /{params+}
method: options
storeTvls100:
handler: src/storeTvls100.default
timeout: 900
events:
- schedule: rate(1 hour)
storeTvls200:
handler: src/storeTvls200.default
timeout: 900
events:
- schedule: rate(1 hour)
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-webpack
- serverless-offline
- serverless-plugin-warmup
- serverless-prune-plugin