From 04e5ad14f6ebd80867670d8f9c2724b145ed029c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wendt?= Date: Wed, 23 Mar 2022 15:59:55 +0100 Subject: [PATCH 1/2] Empty environment is handled correctly local.environment_variables is a merge from: - var.environment_variables (defaults to null) - local.secret_environment_variables (defaults to {}) and even merge(null, null) is an empty map. --- main.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index cb9a24c..f6ecbf4 100644 --- a/main.tf +++ b/main.tf @@ -13,7 +13,9 @@ resource "aws_lambda_function" "this" { role = aws_iam_role.this.arn dynamic "environment" { - for_each = local.environment_variables != null ? [{ variables = local.environment_variables }] : [] + // local.environments is built using a merge, and merges always result in a map + // so we can safely assume we're dealing with a map here. + for_each = length(local.environment_variables) > 0 ? [{ variables = local.environment_variables }] : [] content { variables = environment.value.variables From 5faea368d2ea5e13037f91f6f35b7daea5fbf20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wendt?= Date: Wed, 23 Mar 2022 16:02:40 +0100 Subject: [PATCH 2/2] Add v1.2.1 to CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f3532..f99d3c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.2.1 + +- [Empty environment is handled correctly](https://github.com/babbel/terraform-aws-lambda-with-inline-code/pull/15) + ## v1.2.0 - [Bump hashicorp/aws dependency](https://github.com/babbel/terraform-aws-lambda-with-inline-code/pull/14)