INFO[0004] ╷
│ Error: Missing resource instance key
│
│ on main.tf line 79, in module “mysql”:
│ 79: for user in split(",", nonsensitive(data.vault_generic_secret.vault_additional_users_path.data[“user1”])):
│
│ Because data.vault_generic_secret.vault_additional_users_path has
│ “for_each” set, its attributes must be accessed on specific instances.
│
│ For example, to correlate with indices of a referring resource, use:
│ data.vault_generic_secret.vault_additional_users_path[each.key]
Comes from:
additional_users = [
for user in split(",", nonsensitive(data.vault_generic_secret.vault_additional_users_path.data[“user1”])):
{
name = user
}
]
Hi @ahmad.x.aftab,
That error is trying to explain that the resource data.vault_generic_secret.vault_additional_users_path
is using for_each
, and therefor requires a string key to index a particular instance.
For example, if the instance key is "user1"
, then what you may have meant to use was:
data.vault_generic_secret.vault_additional_users_path["user1"].data
Thanks for the explanation.
You have mentioned for user1
data.vault_generic_secret.vault_additional_users_path[“user1”].data
How do I access an attribute for all the users?
Is there a way to use
data.vault_generic_secret.vault_additional_users_path[“*”].data
did you find the solution for this? am also stuck with the scenario you described
Hi, you can try
output "test" {
values (data.vault_generic_secret.vault_additional_users_path)[“*”].data
}