Skip to content

Commit

Permalink
Set topic iam using variable
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Co <[email protected]>
  • Loading branch information
onimsha committed Jul 24, 2021
1 parent 5c2d4bf commit d7b2f43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ resource "google_pubsub_subscription_iam_member" "push_subscription_binding" {
]
}

resource "google_pubsub_topic_iam_member" "topic_publisher_sa_binding" {
for_each = var.create_topic ? toset(var.allowed_publishers) : []
project = var.project_id
topic = google_pubsub_topic.topic.0.name
role = "roles/pubsub.publisher"
member = each.key
}

resource "google_pubsub_topic" "topic" {
count = var.create_topic ? 1 : 0
project = var.project_id
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ variable "create_topic" {
default = true
}

variable "allowed_publishers" {
type = list(string)
description = "The list of allowed publishers"
default = []
}

variable "topic_labels" {
type = map(string)
description = "A map of labels to assign to the Pub/Sub topic"
Expand Down

0 comments on commit d7b2f43

Please sign in to comment.