Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ EOF
#

resource "aws_iam_role_policy" "lambda" {
role = "${aws_iam_role.lambda.id}"
role = aws_iam_role.lambda.id

policy = <<EOF
{
Expand All @@ -55,26 +55,26 @@ EOF
#

data "template_file" "basic_auth_function" {
template = "${file("${path.module}/functions/basic-auth.js")}"
vars = "${var.basic_auth_credentials}"
template = file("${path.module}/functions/basic-auth.js")
vars = var.basic_auth_credentials
}

data "archive_file" "basic_auth_function" {
type = "zip"
output_path = "${path.module}/functions/basic-auth.zip"

source {
content = "${data.template_file.basic_auth_function.rendered}"
content = data.template_file.basic_auth_function.rendered
filename = "basic-auth.js"
}
}

resource "aws_lambda_function" "basic_auth" {
filename = "${path.module}/functions/basic-auth.zip"
function_name = "${var.function_name}"
role = "${aws_iam_role.lambda.arn}"
function_name = var.function_name
role = aws_iam_role.lambda.arn
handler = "basic-auth.handler"
source_code_hash = "${data.archive_file.basic_auth_function.output_base64sha256}"
source_code_hash = data.archive_file.basic_auth_function.output_base64sha256
runtime = "nodejs12.x"
description = "Protect CloudFront distributions with Basic Authentication"
publish = true
Expand Down
2 changes: 1 addition & 1 deletion module/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "lambda_arn" {
value = "${aws_lambda_function.basic_auth.qualified_arn}"
value = aws_lambda_function.basic_auth.qualified_arn
description = "Lambda function ARN with version"
}