Skip to content

Instantly share code, notes, and snippets.

@jcbagtas
Created April 14, 2020 13:28
Show Gist options
  • Save jcbagtas/231bf08afeecf0ec269296d033faafef to your computer and use it in GitHub Desktop.
Save jcbagtas/231bf08afeecf0ec269296d033faafef to your computer and use it in GitHub Desktop.
Merge a variable List of Maps in Terraform 0.12
# This gist mimics the supposed behavior of
# variable = merge(someListOfMaps[*].parameters...)
# or
# policy_parameters = merge(data.azurerm_policy_definition.d_policy_definitions[*].parameters...)
locals {
policy_parameters = [
for key,value in data.azurerm_policy_definition.d_policy_definitions:
{
parameters = jsondecode(value.parameters)
}
]
ph_parameters = local.policy_parameters[*].parameters
input_parameter = [for item in local.ph_parameters: merge(item,local.ph_parameters...)]
usage = local.input_parameter[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment