Rather than manually declaring keys, you can do something like this
resource "google_storage_bucket_iam_member" "configuration_access" {
for_each = {for i, val in local.service_account_emails: i => val}
bucket = google_storage_bucket.configuration_bucket.name
member = "serviceAccount:${each.value}"
role = "roles/storage.admin"
}
Honestly, I think the many, many issues I see after Googling this error are largely caused by the suggestion in the documentation to use toset()
. Converting your list to a map instead of a set is simply better.
I’ve put my concern in another discussion here, though honestly I don’t know if this is the right forum for it.