From d831d328648b1a539215360f91f4e0f9f3c4e1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Sat, 27 Apr 2024 07:07:04 +0000 Subject: [PATCH] Use default labels on pubsub subscription when no override is provided --- modules/pubsub/README.md | 1 + modules/pubsub/main.tf | 2 +- tests/modules/pubsub/examples/subscriptions.yaml | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/pubsub/README.md b/modules/pubsub/README.md index 6d924d90d..4aaa4a481 100644 --- a/modules/pubsub/README.md +++ b/modules/pubsub/README.md @@ -60,6 +60,7 @@ module "pubsub" { source = "./fabric/modules/pubsub" project_id = var.project_id name = "my-topic" + labels = { test = "default" } subscriptions = { test-pull = {} test-pull-override = { diff --git a/modules/pubsub/main.tf b/modules/pubsub/main.tf index b65d372f1..a090f861b 100644 --- a/modules/pubsub/main.tf +++ b/modules/pubsub/main.tf @@ -54,7 +54,7 @@ resource "google_pubsub_subscription" "default" { project = var.project_id name = each.key topic = google_pubsub_topic.default.name - labels = each.value.labels + labels = coalesce(each.value.labels, var.labels) ack_deadline_seconds = each.value.ack_deadline_seconds message_retention_duration = each.value.message_retention_duration retain_acked_messages = each.value.retain_acked_messages diff --git a/tests/modules/pubsub/examples/subscriptions.yaml b/tests/modules/pubsub/examples/subscriptions.yaml index 89acf08b2..267f4ebc5 100644 --- a/tests/modules/pubsub/examples/subscriptions.yaml +++ b/tests/modules/pubsub/examples/subscriptions.yaml @@ -20,7 +20,8 @@ values: enable_exactly_once_delivery: false enable_message_ordering: false filter: null - labels: null + labels: + test: default message_retention_duration: 604800s name: test-pull project: project-id @@ -52,7 +53,8 @@ values: topic: my-topic module.pubsub.google_pubsub_topic.default: kms_key_name: null - labels: null + labels: + test: default message_retention_duration: null name: my-topic project: project-id