Hello All,
When I attempt to utilize the cluster name from the map below, I receive an error about an Invalid index. could anyone help me solve this please?
> { for name in local.confluent_values : name.service_account => name... }
{
"test" = [
{
"cluster_name" = "dev"
"service_account" = "test"
"topic" = "topic-1"
},
{
"cluster_name" = "nonprod_01"
"service_account" = "test"
"topic" = "topic-3"
},
]
}
module "confluent_service_account" {
for_each = { for name in local.confluent_values : name.service_account => name... }
source = ".//modules/confluent_service_account"
display_name = "${each.key}-service-account"
}
module "api_key" {
source = ".//modules/confluent_api_key"
for_each = {for name in local.confluent_values : "${name.service_account}:${name.cluster_name}" => name }
display_name = "${each.value.service_account}-api-key"
service_account_id = values(module.confluent_service_account)[*].id
cluster_name = each.value.cluster_name
}
╷
│ Error: Invalid index
│
│ on main.tf line 23, in module "api_key":
│ 23: service_account_id = module.confluent_service_account[each.key].id
│ ├────────────────
│ │ each.key is "test:dev"
│ │ module.confluent_service_account is object with 2 attributes
│
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│
│ on main.tf line 23, in module "api_key":
│ 23: service_account_id = module.confluent_service_account[each.key].id
│ ├────────────────
│ │ each.key is "test-1:dev"
│ │ module.confluent_service_account is object with 2 attributes
│
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│
│ on main.tf line 23, in module "api_key":
│ 23: service_account_id = module.confluent_service_account[each.key].id
│ ├────────────────
│ │ each.key is "test:nonprod_01"
│ │ module.confluent_service_account is object with 2 attributes
│
│ The given key does not identify an element in this collection value.
Thanks