Make function name satify AWS constraints and small fixes

This commit is contained in:
Yousef Alam 2018-01-05 15:04:39 +00:00
Родитель 218f05cf91
Коммит 87ff8dd0d6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 10B7403F339660D9
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -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'}];" : ""}

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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}"
}
}