From f7e5ade380206f045dafcce0ec60e37014b315b9 Mon Sep 17 00:00:00 2001 From: Antoine Savignac Date: Mon, 6 Jul 2020 14:39:38 +0100 Subject: [PATCH 1/2] Update string interpolations for terraform >=0.12.0. Update minumum version to 0.12.0 --- examples/node/lambda.tf | 20 ++++++++++---------- examples/node/main.tf | 4 ++-- examples/node/outputs.tf | 2 +- examples/python_get_ssm_parameter/lambda.tf | 20 ++++++++++---------- examples/python_get_ssm_parameter/main.tf | 4 ++-- examples/python_get_ssm_parameter/outputs.tf | 2 +- main.tf | 8 ++++---- outputs.tf | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/examples/node/lambda.tf b/examples/node/lambda.tf index 24e8bfe..4415aed 100644 --- a/examples/node/lambda.tf +++ b/examples/node/lambda.tf @@ -4,7 +4,7 @@ locals { } data "template_file" "lambda_source_file" { - template = "${file("${path.module}/${local.lambda_source_file}")}" + template = file("${path.module}/${local.lambda_source_file}") vars { function_description = "text that is injected into the function" @@ -16,18 +16,18 @@ data "archive_file" "lambda_source_file_zip" { output_path = "${path.module}/${local.lambda_source_file}.zip" source { - content = "${data.template_file.lambda_source_file.rendered}" - filename = "${local.lambda_source_file}" + content = data.template_file.lambda_source_file.rendered + filename = local.lambda_source_file } } resource "aws_lambda_function" "lambda" { - filename = "${substr(data.archive_file.lambda_source_file_zip.output_path, length(path.cwd) + 1, -1)}" - function_name = "${local.function_name}" - role = "${aws_iam_role.lambda.arn}" + filename = substr(data.archive_file.lambda_source_file_zip.output_path, length(path.cwd) + 1, -1) + function_name = local.function_name + role = aws_iam_role.lambda.arn handler = "${local.lambda_source_file_no_ext}.handler" - source_code_hash = "${data.archive_file.lambda_source_file_zip.output_base64sha256}" - runtime = "${local.runtime}" + source_code_hash = data.archive_file.lambda_source_file_zip.output_base64sha256 + runtime = local.runtime description = "MANAGED BY TERRAFORM" } @@ -71,6 +71,6 @@ EOF } resource "aws_iam_role_policy_attachment" "attach-policy" { - role = "${aws_iam_role.lambda.name}" - policy_arn = "${aws_iam_policy.lambda_can_log.arn}" + role = aws_iam_role.lambda.name + policy_arn = aws_iam_policy.lambda_can_log.arn } diff --git a/examples/node/main.tf b/examples/node/main.tf index 9be861d..673e145 100644 --- a/examples/node/main.tf +++ b/examples/node/main.tf @@ -1,6 +1,6 @@ # This example uses locals which were introduced in Terrform 0.10 terraform { - required_version = ">=0.10.4" + required_version = ">=0.12.0" } provider "aws" { @@ -15,7 +15,7 @@ locals { module "execute" { source = "../../" name = "${replace(local.lambda_source_file_no_ext, "_", "-")}-example" - lambda_function_arn = "${aws_lambda_function.lambda.arn}" + lambda_function_arn = aws_lambda_function.lambda.arn lambda_inputs = { alphabet = "abcdefghijklmnopqrstuvwxyz" diff --git a/examples/node/outputs.tf b/examples/node/outputs.tf index 05d1a0a..d3f0d01 100644 --- a/examples/node/outputs.tf +++ b/examples/node/outputs.tf @@ -1,3 +1,3 @@ output "result" { - value = "${module.execute.result}" + value = module.execute.result } diff --git a/examples/python_get_ssm_parameter/lambda.tf b/examples/python_get_ssm_parameter/lambda.tf index 694449a..81c95e6 100644 --- a/examples/python_get_ssm_parameter/lambda.tf +++ b/examples/python_get_ssm_parameter/lambda.tf @@ -4,7 +4,7 @@ locals { } data "template_file" "lambda_source_file" { - template = "${file("${path.module}/${local.lambda_source_file}")}" + template = file("${path.module}/${local.lambda_source_file}") vars { function_description = "text that is injected into the function" @@ -16,18 +16,18 @@ data "archive_file" "lambda_source_file_zip" { output_path = "${path.module}/${local.lambda_source_file}.zip" source { - content = "${data.template_file.lambda_source_file.rendered}" - filename = "${local.lambda_source_file}" + content = data.template_file.lambda_source_file.rendered + filename = local.lambda_source_file } } resource "aws_lambda_function" "lambda" { - filename = "${substr(data.archive_file.lambda_source_file_zip.output_path, length(path.cwd) + 1, -1)}" - function_name = "${local.function_name}" - role = "${aws_iam_role.lambda.arn}" + filename = substr(data.archive_file.lambda_source_file_zip.output_path, length(path.cwd) + 1, -1) + function_name = local.function_name + role = aws_iam_role.lambda.arn handler = "${local.lambda_source_file_no_ext}.handler" - source_code_hash = "${data.archive_file.lambda_source_file_zip.output_base64sha256}" - runtime = "${local.runtime}" + source_code_hash = data.archive_file.lambda_source_file_zip.output_base64sha256 + runtime = local.runtime description = "MANAGED BY TERRAFORM" } @@ -78,6 +78,6 @@ EOF #"Resource": "arn:aws:ssm:*:*:parameter/my_ssm_parameter" resource "aws_iam_role_policy_attachment" "attach-policy" { - role = "${aws_iam_role.lambda.name}" - policy_arn = "${aws_iam_policy.lambda_can_log_and_read_params.arn}" + role = aws_iam_role.lambda.name + policy_arn = aws_iam_policy.lambda_can_log_and_read_params.arn } diff --git a/examples/python_get_ssm_parameter/main.tf b/examples/python_get_ssm_parameter/main.tf index c3ff745..f864734 100644 --- a/examples/python_get_ssm_parameter/main.tf +++ b/examples/python_get_ssm_parameter/main.tf @@ -1,6 +1,6 @@ # This example uses locals which were introduced in Terrform 0.10 terraform { - required_version = ">=0.10.4" + required_version = ">=0.12.0" } provider "aws" { @@ -15,7 +15,7 @@ locals { module "execute" { source = "../../" name = "${replace(local.lambda_source_file_no_ext, "_", "-")}-example" - lambda_function_arn = "${aws_lambda_function.lambda.arn}" + lambda_function_arn = aws_lambda_function.lambda.arn lambda_inputs = { parameter_name = "my_ssm_parameter" diff --git a/examples/python_get_ssm_parameter/outputs.tf b/examples/python_get_ssm_parameter/outputs.tf index 05d1a0a..d3f0d01 100644 --- a/examples/python_get_ssm_parameter/outputs.tf +++ b/examples/python_get_ssm_parameter/outputs.tf @@ -1,3 +1,3 @@ output "result" { - value = "${module.execute.result}" + value = module.execute.result } diff --git a/main.tf b/main.tf index 4ed38d6..af9b668 100644 --- a/main.tf +++ b/main.tf @@ -3,13 +3,13 @@ # --------------------------------------------------------------------------------------------------------------------- terraform { - required_version = ">=0.9.2" + required_version = ">=0.12.0" } resource "aws_cloudformation_stack" "execute_lambda" { - name = "${var.name}" - tags = "${var.tags}" - timeout_in_minutes = "${var.timeout_in_minutes}" + name = var.name + tags = var.tags + timeout_in_minutes = var.timeout_in_minutes template_body = < Date: Mon, 6 Jul 2020 14:50:48 +0100 Subject: [PATCH 2/2] Update variables types to match Terraform >=0.12 requirements --- variables.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/variables.tf b/variables.tf index ad0df61..a8e8384 100644 --- a/variables.tf +++ b/variables.tf @@ -1,17 +1,17 @@ variable "lambda_inputs" { default = {} - type = "map" + type = map(string) description = "Map of inputs which are passed into the Lambda function via the event['ResourceProperties'] object." } variable "lambda_outputs" { - type = "list" + type = list(string) description = "List of outputs from the Lambda function. The Lambda must ALWAYS return these outputs, and they can only be of type String. Maps/Objects will result in a CloudFormation error." } variable "tags" { default = {} - type = "map" + type = map(string) description = "Any tags to add to the CloudFormation stack." }