Skip to content

Commit 59e738a

Browse files
authored
feat: add support for expiration policy ttl in push topic subscriptio… (#226)
1 parent da7a7d4 commit 59e738a

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

examples/pubsub/project/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ module "destination" {
3636
source = "terraform-google-modules/log-export/google//modules/pubsub"
3737
version = "~> 8.0"
3838

39-
project_id = var.project_id
40-
topic_labels = { topic_key : "topic_label" }
41-
topic_name = "pubsub-project-${random_string.suffix.result}"
42-
log_sink_writer_identity = module.log_export.writer_identity
43-
create_subscriber = true
44-
subscription_labels = { subscription_key : "subscription_label" }
39+
project_id = var.project_id
40+
topic_labels = { topic_key : "topic_label" }
41+
topic_name = "pubsub-project-${random_string.suffix.result}"
42+
log_sink_writer_identity = module.log_export.writer_identity
43+
create_subscriber = true
44+
subscription_labels = { subscription_key : "subscription_label" }
45+
push_subscription_expiration_ttl = "300000.5s"
4546
}
4647

modules/pubsub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ so that all dependencies are met.
4343
| log\_sink\_writer\_identity | The service account that logging uses to write log entries to the destination. (This is available as an output coming from the root module). | `string` | n/a | yes |
4444
| project\_id | The ID of the project in which the pubsub topic will be created. | `string` | n/a | yes |
4545
| push\_endpoint | The URL locating the endpoint to which messages should be pushed. | `string` | `""` | no |
46+
| push\_subscription\_expiration\_ttl | Pubsub push subscription expiration policy ttl. | `string` | `null` | no |
4647
| subscriber\_id | The ID to give the pubsub pull subscriber service account (optional). | `string` | `""` | no |
4748
| subscription\_labels | A set of key/value label pairs to assign to the pubsub subscription or pubsub push subscription. | `map(string)` | `{}` | no |
4849
| topic\_labels | A set of key/value label pairs to assign to the pubsub topic. | `map(string)` | `{}` | no |

modules/pubsub/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,11 @@ resource "google_pubsub_subscription" "pubsub_push_subscription" {
109109
push_config {
110110
push_endpoint = var.push_endpoint
111111
}
112+
113+
dynamic "expiration_policy" {
114+
for_each = var.push_subscription_expiration_ttl == null ? [] : [1]
115+
content {
116+
ttl = var.push_subscription_expiration_ttl
117+
}
118+
}
112119
}

modules/pubsub/metadata.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ spec:
102102
type: map(string)
103103
default: {}
104104
required: false
105+
- name: push_subscription_expiration_ttl
106+
description: The expiration policy ttl value to the pubsub push subscription.
107+
type: string
108+
default: null
109+
required: false
105110
- name: topic_labels
106111
description: A set of key/value label pairs to assign to the pubsub topic.
107112
type: map(string)

modules/pubsub/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ variable "subscription_labels" {
3232
description = "A set of key/value label pairs to assign to the pubsub subscription or pubsub push subscription."
3333
}
3434

35+
variable "push_subscription_expiration_ttl" {
36+
description = "Pubsub push subscription expiration policy ttl."
37+
type = string
38+
default = null
39+
}
40+
3541
variable "create_push_subscriber" {
3642
description = "Whether to add a push configuration to the subcription. If 'true', a push subscription is created for push_endpoint"
3743
type = bool

0 commit comments

Comments
 (0)