mirror of
https://github.com/alexgo-io/defillama-server.git
synced 2026-06-12 23:58:39 +08:00
120 lines
3.1 KiB
YAML
120 lines
3.1 KiB
YAML
service: data
|
|
|
|
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 # 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:
|
|
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
|
|
prune:
|
|
automatic: true
|
|
number: 5 # Number of versions to keep
|
|
tableName: ${self:custom.stage}-data-table
|
|
domainMap:
|
|
prod:
|
|
domain: data.llama.fi
|
|
certificateArn: "arn:aws:acm:us-east-1:856461987125:certificate/b4209013-30a6-417e-847e-6e630c3e77fe"
|
|
hostedZone: llama.fi
|
|
dev:
|
|
domain: staging-data.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
|
|
people:
|
|
handler: src/getPeople.default
|
|
timeout: 60
|
|
events:
|
|
- http:
|
|
path: people
|
|
method: get
|
|
corsPreflight:
|
|
handler: src/corsPreflight.default
|
|
events:
|
|
- http:
|
|
path: /{params+}
|
|
method: options
|
|
|
|
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-prune-plugin
|
|
- serverless-plugin-log-retention
|