-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.tf
39 lines (36 loc) · 1.2 KB
/
worker.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
module "worker" {
count = var.worker_lambda_function_name == null ? 1 : 0
source = "./modules/lambda-worker"
lambda_layers = var.worker_lambda_layers
lambda_memory_size = var.worker_lambda_memory_size
lambda_npm_7 = var.worker_lambda_npm_7
lambda_role = var.worker_lambda_role
lambda_timeout = var.worker_lambda_timeout
meta_name = coalesce(var.worker_lambda_function_name, "worker_${var.meta_name}")
}
resource "aws_iam_role_policy" "worker_lambda_s3_access" {
name = "lambda_worker_s3_access"
role = module.worker[0].lambda_worker.role
policy = jsonencode({
Version = "2012-10-17",
Statement = [for v in [
{
Sid = "AllowS3AccessPackageTarget"
Effect = "Allow"
Action = [
"s3:Get*",
"s3:Put*"
]
Resource = "arn:aws:s3:::${var.package_target_s3.bucket}/${var.package_target_s3.prefix}*"
},
var.package_sources_s3 != null ? {
Sid = "AllowS3AccessSources"
Effect = "Allow"
Action = [
"s3:Get*",
]
Resource = "arn:aws:s3:::${var.package_sources_s3.bucket}/${var.package_sources_s3.key}"
} : null
] : v if v != null]
})
}