-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpubsub.tf
26 lines (21 loc) · 947 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
24
25
26
# -----------------------------------------------------
# Setup Pub/Sub Topic
# -----------------------------------------------------
resource "google_pubsub_topic" "pubsub_topic" {
project = var.project_id
name = var.pubsub_topic.name
message_retention_duration = var.pubsub_topic.message_retention_duration
}
# -----------------------------------------------------
# Setup IAM restrictions for topic
# -----------------------------------------------------
resource "google_pubsub_topic_iam_binding" "webapp" {
topic = google_pubsub_topic.pubsub_topic.name
role = "roles/pubsub.publisher"
members = [google_service_account.webapp_service_account.member]
}
resource "google_pubsub_topic_iam_binding" "cloud_function" {
topic = google_pubsub_topic.pubsub_topic.name
role = "roles/pubsub.subscriber"
members = [google_service_account.cloud_function_service_account.member]
}