-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.tf
More file actions
24 lines (22 loc) · 849 Bytes
/
lambda.tf
File metadata and controls
24 lines (22 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data "archive_file" "basicauth" {
count = length(var.authentication) > 0 ? var.enabled ? 1 : 0 : 0
type = "zip"
output_path = "./files/lambda/${var.name}-basicauth.zip"
source {
content = templatefile("${path.module}/templates/basicauth.js", {
authentication = "${jsonencode(var.authentication)}"
})
filename = "index.js"
}
}
resource "aws_lambda_function" "basicauth" {
count = length(var.authentication) > 0 ? var.enabled ? 1 : 0 : 0
provider = aws.useast
filename = data.archive_file.basicauth.0.output_path
function_name = "${var.name}-basicauth"
role = aws_iam_role.lambda.0.arn
handler = "index.handler"
source_code_hash = data.archive_file.basicauth.0.output_base64sha256
runtime = "nodejs16.x"
publish = true
}