-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
executable file
·373 lines (333 loc) · 9.99 KB
/
main.tf
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
provider "aws" {
region = var.region
}
data "aws_caller_identity" "this" {}
locals {
api_version = "v1.0.0"
slice_size_mbp = 5
result_suffix = "_results.tsv"
result_duration = 86400
# layers
binaries_layer = "${aws_lambda_layer_version.binaries_layer.layer_arn}:${aws_lambda_layer_version.binaries_layer.version}"
// python_libraries_layer = module.python_libraries_layer.lambda_layer_arn
python_modules_layer = module.python_modules_layer.lambda_layer_arn
}
#
# initQuery Lambda Function
#
module "lambda-initQuery" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-initQuery"
description = "Invokes queryVCF with the calculated regions"
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 1792
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-initQuery.json
}
source_path = "${path.module}/lambda/initQuery"
tags = var.common-tags
environment ={
variables = {
CONCAT_STARTER_SNS_TOPIC_ARN = aws_sns_topic.concatStarter.arn
QUERY_VCF_SNS_TOPIC_ARN = aws_sns_topic.queryVCF.arn
RESULT_DURATION = local.result_duration
RESULT_SUFFIX = local.result_suffix
SLICE_SIZE_MBP = local.slice_size_mbp
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
HTS_S3_HOST = "s3.${var.region}.amazonaws.com"
}
}
layers = [
local.binaries_layer,
local.python_modules_layer,
]
}
#
# queryVCF Lambda Function
#
module "lambda-queryVCF" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-queryVCF"
description = "Invokes queryGTF for each region."
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-queryVCF.json
}
source_path = "${path.module}/lambda/queryVCF"
tags = var.common-tags
environment ={
variables = {
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
QUERY_GTF_SNS_TOPIC_ARN = aws_sns_topic.queryGTF.arn
QUERY_VCF_SNS_TOPIC_ARN = aws_sns_topic.queryVCF.arn
QUERY_VCF_SUBMIT_SNS_TOPIC_ARN = aws_sns_topic.queryVCFsubmit.arn
SLICE_SIZE_MBP = local.slice_size_mbp
HTS_S3_HOST = "s3.${var.region}.amazonaws.com"
}
}
layers = [
local.binaries_layer,
local.python_modules_layer,
]
}
#
# queryVCFsubmit Lambda Function
#
module "lambda-queryVCFsubmit" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-queryVCFsubmit"
description = "This lambda will be called if there are too many batchids to be processed within"
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-queryVCFsubmit.json
}
source_path = "${path.module}/lambda/queryVCFsubmit"
tags = var.common-tags
environment ={
variables = {
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
QUERY_GTF_SNS_TOPIC_ARN = aws_sns_topic.queryGTF.arn
QUERY_VCF_SUBMIT_SNS_TOPIC_ARN = aws_sns_topic.queryVCFsubmit.arn
}
}
layers = [
local.python_modules_layer
]
}
#
# queryGTF Lambda Function
#
module "lambda-queryGTF" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-queryGTF"
description = "Queries GTF for a specified VCF regions."
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 24
policy = {
json = data.aws_iam_policy_document.lambda-queryGTF.json
}
source_path = "${path.module}/lambda/queryGTF"
tags = var.common-tags
environment ={
variables = {
REFERENCE_LOCATION = aws_s3_bucket.svep-references.bucket
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
REFERENCE_GENOME = "sorted_filtered_Homo_sapiens.GRCh38.109.chr.gtf.gz"
PLUGIN_CONSEQUENCE_SNS_TOPIC_ARN = aws_sns_topic.pluginConsequence.arn
PLUGIN_UPDOWNSTREAM_SNS_TOPIC_ARN = aws_sns_topic.pluginUpdownstream.arn
QUERY_GTF_SNS_TOPIC_ARN = aws_sns_topic.queryGTF.arn
HTS_S3_HOST = "s3.${var.region}.amazonaws.com"
}
}
layers = [
local.binaries_layer,
local.python_modules_layer,
]
}
#
# pluginConsequence Lambda Function
#
# TODO: update source to github.com/bhosking/terraform-aws-lambda once docker support is added
module "lambda-pluginConsequence" {
source = "terraform-aws-modules/lambda/aws"
function_name = "svep-backend-pluginConsequence"
description = "Queries VCF for a specified variant."
create_package = false
image_uri = module.docker_image_pluginConsequence_lambda.image_uri
package_type = "Image"
memory_size = 2048
timeout = 60
attach_policy_jsons = true
policy_jsons = [
data.aws_iam_policy_document.lambda-pluginConsequence.json
]
number_of_policy_jsons = 1
source_path = "${path.module}/lambda/pluginConsequence"
tags = var.common-tags
environment_variables = {
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
REFERENCE_LOCATION = aws_s3_bucket.svep-references.bucket
SPLICE_REFERENCE = "sorted_splice_GRCh38.109.gtf.gz"
MIRNA_REFERENCE = "sorted_filtered_mirna.gff3.gz"
HTS_S3_HOST = "s3.${var.region}.amazonaws.com"
}
}
#
# pluginUpdownstream Lambda Function
#
module "lambda-pluginUpdownstream" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-pluginUpdownstream"
description = "Write upstream and downstream gene variant to temp bucket."
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 24
policy = {
json = data.aws_iam_policy_document.lambda-pluginUpdownstream.json
}
source_path = "${path.module}/lambda/pluginUpdownstream"
tags = var.common-tags
environment ={
variables = {
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
REFERENCE_LOCATION = aws_s3_bucket.svep-references.bucket
REFERENCE_GENOME = "transcripts_Homo_sapiens.GRCh38.109.chr.gtf.gz"
HTS_S3_HOST = "s3.${var.region}.amazonaws.com"
}
}
layers = [
local.binaries_layer,
local.python_modules_layer,
]
}
#
# concat Lambda Function
#
module "lambda-concat" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-concat"
description = "Triggers createPages."
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-concat.json
}
source_path = "${path.module}/lambda/concat"
tags = var.common-tags
environment ={
variables = {
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
CREATEPAGES_SNS_TOPIC_ARN = aws_sns_topic.createPages.arn
}
}
layers = [
local.python_modules_layer
]
}
#
# concatStarter Lambda Function
#
module "lambda-concatStarter" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-concatStarter"
description = "Validates all processing is done and triggers concat"
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 128
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-concatStarter.json
}
source_path = "${path.module}/lambda/concatStarter"
tags = var.common-tags
environment ={
variables = {
SVEP_TEMP = aws_s3_bucket.svep-temp.bucket
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
CONCAT_SNS_TOPIC_ARN = aws_sns_topic.concat.arn
CONCAT_STARTER_SNS_TOPIC_ARN = aws_sns_topic.concatStarter.arn
}
}
layers = [
local.python_modules_layer,
]
}
#
# createPages Lambda Function
#
module "lambda-createPages" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-createPages"
description = "concatenates individual page with 700 entries, received from concat lambda"
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-createPages.json
}
source_path = "${path.module}/lambda/createPages"
tags = var.common-tags
environment ={
variables = {
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
SVEP_RESULTS = var.data_portal_bucket_name
CONCATPAGES_SNS_TOPIC_ARN = aws_sns_topic.concatPages.arn
CREATEPAGES_SNS_TOPIC_ARN = aws_sns_topic.createPages.arn
}
}
layers = [
local.python_modules_layer,
]
}
#
# concatPages Lambda Function
#
module "lambda-concatPages" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-concatPages"
description = "concatenates all the page files created by createPages lambda."
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 2048
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-concatPages.json
}
source_path = "${path.module}/lambda/concatPages"
tags = var.common-tags
environment ={
variables = {
RESULT_SUFFIX = local.result_suffix
SVEP_REGIONS = aws_s3_bucket.svep-regions.bucket
SVEP_RESULTS = var.data_portal_bucket_name
CONCATPAGES_SNS_TOPIC_ARN = aws_sns_topic.concatPages.arn
}
}
layers = [
local.python_modules_layer
]
}
#
# getResultsURL Lambda Function
#
module "lambda-getResultsURL" {
source = "github.com/bhosking/terraform-aws-lambda"
function_name = "svep-backend-getResultsURL"
description = "Returns the presigned results URL for results"
handler = "lambda_function.lambda_handler"
runtime = "python3.12"
memory_size = 1792
timeout = 28
policy = {
json = data.aws_iam_policy_document.lambda-getResultsURL.json
}
source_path = "${path.module}/lambda/getResultsURL"
tags = var.common-tags
environment ={
variables = {
REGION = var.region
RESULT_DURATION = local.result_duration
RESULT_SUFFIX = local.result_suffix
SVEP_RESULTS = var.data_portal_bucket_name
}
}
layers = [
local.python_modules_layer,
]
}