Skip to content

Commit

Permalink
feat: add pubsub iam member for bigquery subscription dead letter top…
Browse files Browse the repository at this point in the history
…ics (#146)
  • Loading branch information
tcoyze authored Nov 21, 2023
1 parent d1298c0 commit a413f03
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ resource "google_pubsub_topic_iam_member" "pull_topic_binding" {
]
}

resource "google_pubsub_topic_iam_member" "bigquery_topic_binding" {
for_each = var.create_topic ? { for i in var.bigquery_subscriptions : i.name => i if try(i.dead_letter_topic, "") != "" } : {}

project = var.project_id
topic = each.value.dead_letter_topic
role = "roles/pubsub.publisher"
member = "serviceAccount:${local.pubsub_svc_account_email}"
depends_on = [
google_pubsub_topic.topic,
]
}

resource "google_pubsub_subscription_iam_member" "pull_subscription_binding" {
for_each = var.create_subscriptions ? { for i in var.pull_subscriptions : i.name => i if try(i.dead_letter_topic, "") != "" } : {}

Expand All @@ -110,6 +122,18 @@ resource "google_pubsub_subscription_iam_member" "push_subscription_binding" {
]
}

resource "google_pubsub_subscription_iam_member" "bigquery_subscription_binding" {
for_each = var.create_subscriptions ? { for i in var.bigquery_subscriptions : i.name => i if try(i.dead_letter_topic, "") != "" } : {}

project = var.project_id
subscription = each.value.name
role = "roles/pubsub.subscriber"
member = "serviceAccount:${local.pubsub_svc_account_email}"
depends_on = [
google_pubsub_subscription.bigquery_subscriptions,
]
}

resource "google_pubsub_topic" "topic" {
count = var.create_topic ? 1 : 0
project = var.project_id
Expand Down

0 comments on commit a413f03

Please sign in to comment.