This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
70 lines (49 loc) · 1.51 KB
/
main.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Enables the API to manage resources
resource "google_project_service" "pubsub-api" {
project = var.project_id
service = "pubsub.googleapis.com"
}
# Variables to use in the file
locals {
diff_sa = "${var.dialect_map_diff_sa_name}@${var.project_id}.iam.gserviceaccount.com"
jobs_sa = "${var.dialect_map_jobs_sa_name}@${var.project_id}.iam.gserviceaccount.com"
}
# List of resources associated to the module
resource "google_pubsub_topic" "data-diff-topic" {
name = "data-diff"
labels = {
env : "production"
}
}
resource "google_pubsub_subscription" "data-diff-static-sub" {
name = "static-data-job"
topic = google_pubsub_topic.data-diff-topic.name
labels = {
env : "production"
job : "static-data"
}
# Maximum number of seconds to ACK a message
ack_deadline_seconds = 600
# Whether to preserve messages in a backlog
retain_acked_messages = false
# Subscription expiration (empty TTL means never)
expiration_policy {
ttl = ""
}
}
# List of Pub/Sub permission roles
resource "google_pubsub_topic_iam_binding" "diff-topic-publisher-binding" {
project = var.project_id
topic = google_pubsub_topic.data-diff-topic.name
role = "roles/pubsub.publisher"
members = [
"serviceAccount:${local.diff_sa}",
]
}
resource "google_pubsub_subscription_iam_binding" "static-subscription-binding" {
subscription = google_pubsub_subscription.data-diff-static-sub.name
role = "roles/pubsub.subscriber"
members = [
"serviceAccount:${local.jobs_sa}",
]
}