From 332aa5657cfd150f428c1d5ca969604f3bd04cfd Mon Sep 17 00:00:00 2001 From: Michal Kimle Date: Wed, 29 Mar 2023 17:49:46 +0200 Subject: [PATCH] Fix Terraform secrets parsing for older TF version --- .../terraform/aws/modules/function/variables.tf | 2 +- .../terraform/gcp/modules/function/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/airnode-deployer/terraform/aws/modules/function/variables.tf b/packages/airnode-deployer/terraform/aws/modules/function/variables.tf index d787a92771..b2523656aa 100644 --- a/packages/airnode-deployer/terraform/aws/modules/function/variables.tf +++ b/packages/airnode-deployer/terraform/aws/modules/function/variables.tf @@ -10,7 +10,7 @@ locals { # Trim whitespaces from the line secrets_lines_trimmed = [for line in local.secrets_lines : trimspace(line)] # Discard commented lines (starting with '#') - secrets_lines_uncommented = [for line in local.secrets_lines_trimmed : line if !startswith(line, "#")] + secrets_lines_uncommented = [for line in local.secrets_lines_trimmed : line if can(regex("^[^#]+.*$", line))] # Discard lines not matching the pattern and split them. We're looking for line that has non-whitespace characters before '=' and anything after secrets_lines_matched = [for line in local.secrets_lines_uncommented : regex("^([^[:space:]]+?)=(.*)$", line) if can(regex("^([^[:space:]]+?)=(.*)$", line))] # Convert the list to a map, remove quotation marks around the values. When duplicate keys are encountered the last found value is used. diff --git a/packages/airnode-deployer/terraform/gcp/modules/function/variables.tf b/packages/airnode-deployer/terraform/gcp/modules/function/variables.tf index 410fa89270..6377727567 100644 --- a/packages/airnode-deployer/terraform/gcp/modules/function/variables.tf +++ b/packages/airnode-deployer/terraform/gcp/modules/function/variables.tf @@ -14,7 +14,7 @@ locals { # Trim whitespaces from the line secrets_lines_trimmed = [for line in local.secrets_lines : trimspace(line)] # Discard commented lines (starting with '#') - secrets_lines_uncommented = [for line in local.secrets_lines_trimmed : line if !startswith(line, "#")] + secrets_lines_uncommented = [for line in local.secrets_lines_trimmed : line if can(regex("^[^#]+.*$", line))] # Discard lines not matching the pattern and split them. We're looking for line that has non-whitespace characters before '=' and anything after secrets_lines_matched = [for line in local.secrets_lines_uncommented : regex("^([^[:space:]]+?)=(.*)$", line) if can(regex("^([^[:space:]]+?)=(.*)$", line))] # Convert the list to a map, remove quotation marks around the values. When duplicate keys are encountered the last found value is used.