diff --git a/headers_function.js b/headers_function.js index b065367..c9e5aee 100644 --- a/headers_function.js +++ b/headers_function.js @@ -4,7 +4,7 @@ exports.handler = (event, context, callback) => { const response = event.Records[0].cf.response; const headers = response.headers; - // See https://wiki.mozilla.org/Security/Guidelines/Web_Security + // See https://wiki.mozilla.org/Security/Guidelines/Web_Security b ${hsts ? "headers['Strict-Transport-Security'] = [{'key': 'Strict-Transport-Security', 'value': 'max-age=63072000'}];" : ""} ${x-content-type ? "headers['X-Content-Type-Options'] = [{'key': 'X-Content-Type-Options', 'value': 'nosniff'}];" : ""} ${x-frame-options ? "headers['X-Frame-Options'] = [{'key': 'X-Frame-Options', 'value': 'DENY'}];" : ""} diff --git a/lambda.tf b/lambda.tf index d436d09..5885e12 100644 --- a/lambda.tf +++ b/lambda.tf @@ -58,7 +58,7 @@ resource "aws_iam_role_policy_attachment" "headers-function-role-policy" { resource "aws_lambda_function" "headers" { count = "${var.headers["enabled"] ? 1 : 0}" - function_name = "${var.alias}-headers" + function_name = "${replace(var.alias, ".", "-")}-headers" filename = "${data.archive_file.headers-function.output_path}" source_code_hash = "${data.archive_file.headers-function.output_base64sha256}" role = "${aws_iam_role.headers-function.arn}" @@ -66,5 +66,5 @@ resource "aws_lambda_function" "headers" { handler = "index.handler" memory_size = 128 timeout = 3 - publish = false + publish = true } diff --git a/main.tf b/main.tf index ecb94c8..ecdae49 100644 --- a/main.tf +++ b/main.tf @@ -70,7 +70,7 @@ resource "aws_cloudfront_distribution" "ssl_distribution" { cached_methods = ["GET", "HEAD"] target_origin_id = "${var.origin_id}" compress = "${var.compression}" - path_pattern = "/" + path_pattern = "*" forwarded_values { query_string = false @@ -88,7 +88,7 @@ resource "aws_cloudfront_distribution" "ssl_distribution" { event_type = "${var.headers["enabled"] ? "viewer-response" : ""}" // this currently does not work in Terraform //lambda_arn = "${var.headers["enabled"] ? aws_lambda_function.headers.arn : ""}" - lambda_arn = "${aws_lambda_function.headers.arn}" + lambda_arn = "${aws_lambda_function.headers.arn}:${aws_lambda_function.headers.version}" } }