Skip to content

Commit

Permalink
feat: Add token creator binding for service account (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakovt authored Nov 12, 2020
1 parent 4972a25 commit 112607c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ locals {
pubsub_svc_account_email = "service-${data.google_project.project.number}@gcp-sa-pubsub.iam.gserviceaccount.com"
}

resource "google_project_iam_member" "token_creator_binding" {
project = var.project_id
role = "roles/iam.serviceAccountTokenCreator"
member = "serviceAccount:${local.pubsub_svc_account_email}"
depends_on = [
google_pubsub_subscription.push_subscriptions,
]
}

resource "google_pubsub_topic_iam_member" "push_topic_binding" {
count = var.create_topic ? length(var.push_subscriptions) : 0
project = var.project_id
Expand Down
3 changes: 2 additions & 1 deletion test/setup/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
locals {
int_required_roles = [
"roles/cloudiot.admin",
"roles/pubsub.admin"
"roles/pubsub.admin",
"roles/resourcemanager.projectIamAdmin"
]
}

Expand Down

0 comments on commit 112607c

Please sign in to comment.