-
Notifications
You must be signed in to change notification settings - Fork 20
/
serverless.yml
208 lines (193 loc) · 4.92 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
service: lucene-serverless
variablesResolutionMode: 20210219
# TODO: replace all variables below
custom:
name: ${sls:stage}-${self:service}
region: ${opt:region, "us-east-1"}
vpcId: vpc-00690f6e
subnetId1: subnet-039f496e
subnetId2: subnet-0c0af8ea
frameworkVersion: ">=1.56.1"
provider:
name: aws
region: ${self:custom.region}
versionFunctions: false
apiGateway:
shouldStartNameWithService: true
tracing:
lambda: false
timeout: 15
environment:
stage: prod
DISABLE_SIGNAL_HANDLERS: true
iam:
role:
statements: ${file(roleStatements.yml)}
vpc:
securityGroupIds:
- Ref: EfsSecurityGroup
subnetIds:
- ${self:custom.subnetId1}
- ${self:custom.subnetId2}
package:
individually: true
functions:
query:
name: ${self:custom.name}-query
runtime: provided
handler: native.handler
provisionedConcurrency: 1 # ~$2.5/m, lower cold start time
memorySize: 256
events:
- http: POST /query
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [EfsAccessPoint, Arn]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: query
QUARKUS_PROFILE: prod
index:
name: ${self:custom.name}-index
runtime: provided
handler: native.handler
reservedConcurrency: 1
memorySize: 256
timeout: 180
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [EfsAccessPoint, Arn]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: index
QUARKUS_PROFILE: prod
events:
- sqs:
arn:
Fn::GetAtt: [WriteQueue, Arn]
batchSize: 5000
maximumBatchingWindow: 5
enqueue-index:
name: ${self:custom.name}-enqueue-index
runtime: provided
handler: native.handler
memorySize: 256
package:
artifact: target/function.zip
vpc:
securityGroupIds: []
subnetIds: []
events:
- http: POST /index
environment:
QUARKUS_LAMBDA_HANDLER: enqueue-index
QUARKUS_PROFILE: prod
QUEUE_URL:
Ref: WriteQueue
delete-index:
name: ${self:custom.name}-delete-index
runtime: provided
handler: native.handler
memorySize: 256
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [EfsAccessPoint, Arn]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: deleteIndex
QUARKUS_PROFILE: prod
resources:
Resources:
WriteQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.name}-write-queue
VisibilityTimeout: 900
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt: [WriteDLQ, Arn]
maxReceiveCount: 5
WriteDLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.name}-write-dlq
MessageRetentionPeriod: 1209600 # 14 days in seconds
FileSystem:
Type: AWS::EFS::FileSystem
Properties:
BackupPolicy:
Status: DISABLED
FileSystemTags:
- Key: Name
Value: ${self:custom.name}-fs
PerformanceMode: generalPurpose
ThroughputMode: elastic # faster scale up/down
Encrypted: true
FileSystemPolicy:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "elasticfilesystem:ClientMount"
Principal:
AWS: "*"
EfsSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: ${self:custom.vpcId}
GroupDescription: "mnt target sg"
SecurityGroupIngress:
- IpProtocol: -1
CidrIp: "0.0.0.0/0"
- IpProtocol: -1
CidrIpv6: "::/0"
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: "0.0.0.0/0"
- IpProtocol: -1
CidrIpv6: "::/0"
EfsMountTarget1:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref FileSystem
SubnetId: ${self:custom.subnetId1}
SecurityGroups:
- Ref: EfsSecurityGroup
EfsMountTarget2:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref FileSystem
SubnetId: ${self:custom.subnetId2}
SecurityGroups:
- Ref: EfsSecurityGroup
EfsAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref FileSystem
PosixUser:
Uid: "1000"
Gid: "1000"
RootDirectory:
CreationInfo:
OwnerGid: "1000"
OwnerUid: "1000"
Permissions: "0777"
Path: "/mnt/data"