Akhil Amit Senroy
Akhil Amit Senroy

Reputation: 35

How to create an Eventarc trigger in terraform for Pub/Sub?

I need to create an eventarc trigger on a Pub/Sub message published. I do not know where to put the Pub/Sub topic ID.

resource "google_eventarc_trigger" "eventarc_trigger" {
  name            = "test-trigger"
  service_account = var.service_account
  project = local.project
  location = local.region
  destination {
    workflow = google_workflows_workflow.example.id
  }

  matching_criteria {
    attribute = "type"
    value = "google.cloud.pubsub.topic.v1.messagePublished"
  }
}

Upvotes: 1

Views: 1489

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75930

You can define the target transport like that

resource "google_eventarc_trigger" "eventarc_trigger" {
  name            = "test-trigger"
  service_account = var.service_account
  project = local.project
  location = local.region
  destination {
    workflow = google_workflows_workflow.example.id
  }

  matching_criteria {
    attribute = "type"
    value = "google.cloud.pubsub.topic.v1.messagePublished"
  }

  transport {
    pubsub {
      topic = "projects/{PROJECT_ID}/topics/{TOPIC_NAME}"
    }
  }
}

Upvotes: 3

Related Questions