Skip to content

Commit b1093e6

Browse files
authored
fix(cloudevent-trigger): Use standard labels (#1083)
The product & team variables existed but weren't being applied to all resources. Part of: - chainguard-dev/internal-dev#13973
1 parent ceb8b19 commit b1093e6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/cloudevent-trigger/main.tf

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ locals {
5050
[for key in var.filter_has_attributes : "attributes:ce-${key}"],
5151
[for key in var.filter_not_has_attributes : "NOT attributes:ce-${key}"],
5252
)
53+
54+
default_labels = {
55+
basename(abspath(path.module)) = var.name
56+
terraform-module = basename(abspath(path.module))
57+
team = var.team
58+
product = var.product
59+
}
5360
}
5461

5562
resource "google_pubsub_topic" "dead-letter" {
5663
name = "${var.name}-dlq-${random_string.suffix.result}"
5764

58-
labels = merge(
59-
var.team == "" ? {} : { team = var.team },
60-
var.product == "" ? {} : { product = var.product }
61-
)
65+
labels = local.default_labels
6266

6367
message_storage_policy {
6468
allowed_persistence_regions = [var.private-service.region]
@@ -79,6 +83,8 @@ resource "google_storage_bucket" "dlq_bucket" {
7983
location = var.gcs_region
8084

8185
uniform_bucket_level_access = true
86+
87+
labels = local.default_labels
8288
}
8389

8490
// Allow the subscription to publish to the dead letter bucket
@@ -117,6 +123,7 @@ resource "google_pubsub_subscription" "dead-letter-pull-sub" {
117123
name = google_pubsub_topic.dead-letter.name
118124
topic = google_pubsub_topic.dead-letter.name
119125
message_retention_duration = "86400s"
126+
labels = local.default_labels
120127

121128
expiration_policy {
122129
ttl = "86400s"
@@ -145,8 +152,9 @@ resource "google_pubsub_subscription" "dead-letter-pull-sub" {
145152
// Configure the subscription to deliver the events matching our filter to this service
146153
// using the above identity to authorize the delivery..
147154
resource "google_pubsub_subscription" "this" {
148-
name = "${var.name}-${random_string.suffix.result}"
149-
topic = var.broker
155+
name = "${var.name}-${random_string.suffix.result}"
156+
topic = var.broker
157+
labels = local.default_labels
150158

151159
ack_deadline_seconds = var.ack_deadline_seconds
152160

0 commit comments

Comments
 (0)