Skip to content

Commit

Permalink
Fix Terraform secrets parsing for older TF version
Browse files Browse the repository at this point in the history
  • Loading branch information
amarthadan committed Mar 29, 2023
1 parent 6cfc8f2 commit 332aa56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 332aa56

Please sign in to comment.