Hi Guys,
I am trying to run the module in the loop to deploy multiple resources of my module. I just did the quick search and found we can’t do that. I just want to know if there is any other way we can achieve this. here is the code
module "azurepolicy_assignments" {
source = "./Modules/AzurePolicyAssignement/"
count = length(local.policies)
policy_display_name = local.policies[count.index].policy_display_name
assignment_name = local.policies[count.index].assignment_name
policy_scope = azurerm_resource_group.hub_rg.name
assignment_display_name = local.policies[count.index].assignment_display_name
assignment_description = local.policies[count.index].assignment_description
policy_parameters = local.policies[count.index].policy_parameters
resource_exclusion_list = local.policies[count.index].resource_exclusion_list
identity_type = local.policies[count.index].identity_type
}
here is what I have in my local.tf file.
locals {
policies = [
{
policy_display_name = "Allowed locations"
assignment_name = "test2"
assignment_display_name = "Test Policy Resources"
assignment_description = "TESTING THE POLICY WITH THE LOOP"
policy_parameters = jsonencode({
"listOfAllowedLocations": {
"value": var.listOfAllowedLocations
}
})
resource_exclusion_list = []
identity_type = "none"
},
{
policy_display_name = "Allowed locations for resource groups"
assignment_name = "test3"
assignment_display_name = "Test Policy RG"
assignment_description = "TESTING THE POLICY WITH THE LOOP REsource gorup"
policy_parameters = jsonencode({
"listOfAllowedLocations": {
"value": var.listOfAllowedLocations
}
})
resource_exclusion_list = []
identity_type = "none"
}
]
}
any other way to achieve this at all ?