-
Notifications
You must be signed in to change notification settings - Fork 5
/
serverless.yml
150 lines (136 loc) · 4.66 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
service: serverless-duckdb
frameworkVersion: '3'
plugins:
- serverless-iam-roles-per-function
- serverless-prune-plugin
- serverless-esbuild
custom:
# API details
api:
version: 'v1'
# Availability Zone info
# See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-networking.html#s3-express-endpoints
# us-east-1 / az4
# Uncomment if you want to use S3 Express One Zone
# s3:
# availabilityZoneId: 'use1-az4'
# bucketName: 'serverless-duckdb--${self:custom.s3.availabilityZoneId}--x-s3'
# esbuild plugin
esbuild:
bundle: true
minify: false
exclude:
- 'duckdb'
- 'aws-lambda'
- 'dtrace-provider'
# Prune plugin
prune:
automatic: true
number: 3
provider:
name: aws
runtime: nodejs16.x
region: ${opt:region, 'us-east-1'}
stage: 'prd'
logRetentionInDays: 14
apiGateway:
apiKeys:
- DuckDBApiKey
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1' # Enable HTTP keep-alive connections for the AWS SDK
# See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-networking.html#s3-express-endpoints
# Uncomment if you want to use S3 Express One Zone
# AWS_S3_ONE_ZONE_EXPRESS_ENDPOINT: 's3express-${self:custom.s3.availabilityZoneId}.${self:provider.region}.amazonaws.com'
STAGE: '${self:provider.stage}'
LOG_LEVEL: 'debug'
functions:
# Streaming Lambda function: Will return results as Apache Arrow IPC stream
streamingQuery:
handler: src/functions/streamingQuery.handler
memorySize: 2048
timeout: 30
url:
invokeMode: RESPONSE_STREAM
layers:
# Latest x86 layer
- 'arn:aws:lambda:${self:provider.region}:041475135427:layer:duckdb-nodejs-x86:13'
# Request-Response Lambda function: Will return results as JSON en bloc
query:
handler: src/functions/query.handler
memorySize: 2048
timeout: 30
# Enable this for arm64 support
# architecture: arm64
# Enable this for custom IAM roles for S3 access
# iamRoleStatements:
# # Read from input bucket
# - Effect: Allow
# Action:
# - s3:GetObject
# Resource: 'arn:aws:s3:::YOUR-S3-INPUT-BUCKET-NAME/*'
# - Effect: Allow
# Action:
# - s3:ListBucket
# Resource: 'arn:aws:s3:::YOUR-S3-INPUT-BUCKET-NAME'
# # If you want to write to another output bucket, use the statements below
# # (or use the same bucket name as the input bucket if you want to write to it as well)
# - Effect: Allow
# Action:
# - s3:ListBucket
# - s3:ListBucketMultipartUploads
# Resource: 'arn:aws:s3:::YOUR-S3-OUTPUT-BUCKET-NAME'
# - Effect: Allow
# Action:
# - s3:GetObject
# - s3:PutObject
# - s3:AbortMultipartUpload
# - s3:ListMultipartUploadParts
# Resource: 'arn:aws:s3:::YOUR-S3-OUTPUT-BUCKET-NAME/*'
layers:
# Latest x86_64 layer
- 'arn:aws:lambda:${self:provider.region}:041475135427:layer:duckdb-nodejs-x86:13'
# Latest arm64 layer
# - 'arn:aws:lambda:${self:provider.region}:041475135427:layer:duckdb-nodejs-arm64:11'
events:
- http:
path: ${self:custom.api.version}/query
method: post
cors: true
private: true
# Uncomment if you want to use S3 Express One Zone
# queryS3Express:
# handler: src/functions/queryS3Express.handler
# # Max memory and thus vCPUs
# memorySize: 10240
# # Max timeout for API Gateway REST APIs
# timeout: 30
# # Enable this for custom IAM roles for S3 access
# iamRoleStatements:
# # Read from S3 Express One Zone bucket
# # See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-security-iam.html#s3-express-security-iam-authorization
# - Effect: Allow
# Action:
# - s3express:CreateSession
# Resource: !Join [':', [ 'arn:aws:s3express', '${self:provider.region}', !Ref 'AWS::AccountId', 'bucket/${self:custom.s3.bucketName}' ]]
# layers:
# # Latest x86_64 extensions layer (includes aws, arrow, httpfs)
# - 'arn:aws:lambda:${self:provider.region}:041475135427:layer:duckdb-extensions-nodejs-x86:6'
# vpc:
# securityGroupIds:
# - !GetAtt VpcEndpointLambdaSecurityGroup.GroupId
# subnetIds:
# - !GetAtt PrivateASubnet.SubnetId
# events:
# - http:
# path: ${self:custom.api.version}/queryS3Express
# method: post
# cors: true
# private: true
resources:
# Uncomment if you want to use S3 Express One Zone
# # VPC
# - ${file(resources/vpc.yml)}
# # S3 One Zone Express
# - ${file(resources/s3.yml)}
package:
individually: true