-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
41 lines (29 loc) · 1.03 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
resource "google_pubsub_topic" "topic" {
count = var.module_enabled ? 1 : 0
project = var.project
name = var.name
labels = var.labels
kms_key_name = var.kms_key_name
message_retention_duration = var.message_retention_duration
dynamic "message_storage_policy" {
for_each = var.allowed_persistence_regions != null ? [1] : []
content {
allowed_persistence_regions = var.allowed_persistence_regions
}
}
dynamic "schema_settings" {
for_each = can(var.schema.name) || can(var.schema.id) ? [1] : []
content {
schema = can(var.schema.name) ? try(google_pubsub_schema.schema[var.schema.name].id, null) : var.schema.id
encoding = try(var.schema.encoding, "ENCODING_UNSPECIFIED")
}
}
depends_on = [var.module_depends_on]
}
resource "google_pubsub_schema" "schema" {
for_each = can(var.schema.name) ? { (var.schema.name) = var.schema } : {}
project = var.project
name = each.key
type = try(each.value.type, null)
definition = try(each.value.definition, null)
}