Skip to content

Commit

Permalink
Merge pull request #2 from konpyutaika/fix/add_project_binding
Browse files Browse the repository at this point in the history
[Fix] - add project binding
  • Loading branch information
erdrix authored Sep 24, 2023
2 parents 026afb3 + bbdfb2e commit e030ba5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions project-bindings.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

# Association user <-> role
locals {
project_pair_binding = flatten([
for user, roles in var.project_bindings : [
for role in roles : {
user = user
role = role
}
]
])
}

resource "google_project_iam_member" "project_iam_member_binding" {
for_each = {
for binding in distinct(local.project_pair_binding) : "${binding.user}.${binding.role}" => binding
}

#id = "${var.project_id}/${each.value.role}/${each.value.user}"
project = var.project_id
role = each.value.role
member = each.value.user

depends_on = [
google_service_account.project_service_account, # in case bindings refers to service account
google_project_iam_custom_role.project_custom_role_map # in case bindings refers to custom roles
]
}

0 comments on commit e030ba5

Please sign in to comment.