"for_each" set, its attributes must be accessed on specific

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