-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubsub.tf
23 lines (19 loc) · 809 Bytes
/
pubsub.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
resource "google_pubsub_topic" "topic" {
name = "trigger-topic"
depends_on = [null_resource.enable_apis]
}
resource "google_storage_notification" "notification" {
bucket = google_storage_bucket.dataset.name
payload_format = "JSON_API_V1"
topic = google_pubsub_topic.topic.id
event_types = ["OBJECT_FINALIZE"]
depends_on = [google_pubsub_topic_iam_binding.binding]
}
// Enable notifications by giving the correct IAM permission to the unique service account.
data "google_storage_project_service_account" "gcs_account" {
}
resource "google_pubsub_topic_iam_binding" "binding" {
topic = google_pubsub_topic.topic.id
role = "roles/pubsub.publisher"
members = ["serviceAccount:${data.google_storage_project_service_account.gcs_account.email_address}"]
}