Hello,
My terraform is displaying this error message and I don’t know exactly why …
Error: Invalid index
│
│ on .terraform/modules/grafana_user/main.tf line 40, in locals:
│ 40: ])[0]
│ ├────────────────
│ │ data.ldap_object.ldap_user_attributes.attributes is set of map of string with 1 element
Here is the code to create the local variables:
locals {
grafana_users = toset([
for item in local.groups.grafana_users :
split(":", item)[0]
])
}
When I am displaying the value with an output, I have this:
test = [
+ “toto1”,
+ “toto2”,
+ “toto3”,
+ “toto4”,
+ “toto5”,
+ “toto6”,
]
But when I want to use this local variable in the code below, I have the error Invalid index:
module "grafana_user" {
for_each = { for user in local.grafana_users : user => user }
source = "git@...:terraform-modules/terraform-grafana-user.git?ref=v1.1.0"
ldap_login = each.value
}
Any help is welcome …