forked from ArsenyYankovsky/lucene-serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
205 lines (189 loc) · 5.08 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
service: lucene-serverless
variablesResolutionMode: 20210326
custom:
name: ${sls:stage}-${self:service}
region: ${opt:region, self:provider.region}
vpcId: vpc-8aa25ee3 # TODO: replace with your VPC settings region
subnetId1: subnet-efd7e8a5 # TODO: replace with your VPC settings region
subnetId2: subnet-7a4b5702 # TODO: replace with your VPC settings region
subnetId3: subnet-486d9f21 # TODO: replace with your VPC settings region
frameworkVersion: ">=1.56.1"
provider:
name: aws
region: eu-north-1 # TODO: replace with your region
versionFunctions: false
tracing: false
timeout: 15
environment:
stage: ${sls:stage}
DISABLE_SIGNAL_HANDLERS: true
iamRoleStatements:
${file(roleStatements.yml)}
vpc:
securityGroupIds:
- Ref: EfsSecurityGroup
subnetIds:
- ${self:custom.subnetId1}
- ${self:custom.subnetId2}
- ${self:custom.subnetId3}
package:
individually: true
functions:
query:
name: ${self:custom.name}-query
runtime: provided
handler: native.handler
events:
- http: POST /query
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsMountTarget3
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [ EfsAccessPoint, Arn ]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: query
QUARKUS_PROFILE: ${sls:stage}
index:
name: ${self:custom.name}-index
runtime: provided
handler: native.handler
reservedConcurrency: 1
timeout: 180
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsMountTarget3
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [ EfsAccessPoint, Arn ]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: index
QUARKUS_PROFILE: ${sls:stage}
events:
- sqs:
arn:
Fn::GetAtt: [ WriteQueue, Arn ]
batchSize: 5000
maximumBatchingWindow: 5
enqueue-index:
name: ${self:custom.name}-enqueue-index
runtime: provided
handler: native.handler
package:
artifact: target/function.zip
vpc:
securityGroupIds: [ ]
subnetIds: [ ]
events:
- http: POST /index
environment:
QUARKUS_LAMBDA_HANDLER: enqueue-index
QUARKUS_PROFILE: ${sls:stage}
QUEUE_URL:
Ref: WriteQueue
delete-index:
name: ${self:custom.name}-delete-index
runtime: provided
handler: native.handler
dependsOn:
- EfsMountTarget1
- EfsMountTarget2
- EfsMountTarget3
- EfsAccessPoint
fileSystemConfig:
localMountPath: /mnt/data
arn:
Fn::GetAtt: [ EfsAccessPoint, Arn ]
package:
artifact: target/function.zip
environment:
QUARKUS_LAMBDA_HANDLER: deleteIndex
QUARKUS_PROFILE: ${sls:stage}
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
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"
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: "0.0.0.0/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
EfsMountTarget3:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref FileSystem
SubnetId: ${self:custom.subnetId3}
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"