Hello, I have the following data structure, and I have a module that needs to loop over this map:
webapps = {
w1= {
site_config = {}
slots = {
dev = {
site_config = {}
},
uat-staging = {
site_config = {
site_config = {}
}
},
uat-live = {
site_config = {
site_config = {}
}
},
production-stage = {
site_config = {
site_config = {}
}
}
}
core_app_service_to_blob_role_assignment = {
app = ["container1", "container2"]
audit = ["container3", "container4"]
}
}
}
I call the module with a for_each and for loops which should generate a new map with a key = webapp name (w1) and value = core_app_service_to_blob_role_assignment :
module "role-assignment" {
providers = {
azurerm = azurerm
azurerm.central = azurerm.central
}
for_each = {for k, v in var.webapps : k => { for sa, container in v.core_app_service_to_blob_role_assignment : sa => container }}
source = "./modules/role-assignment"
assignments = each.value["app"]
principle_id = module.app-service-core[each.key].app_service_slot_identity_service_principal_id
}
But getting the following error:
│ Error: Invalid index
│
│ on main.tf line 102, in module "role-assignment":
│ 102: assignments = each.value["app"]
│ ├────────────────
│ │ each.value is object with no attributes
│
│ The given key does not identify an element in this collection value.