diff --git a/modules/pubsub/README.md b/modules/pubsub/README.md
index a321c662e..74d0b8ac5 100644
--- a/modules/pubsub/README.md
+++ b/modules/pubsub/README.md
@@ -94,17 +94,18 @@ module "pubsub" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [name](variables.tf#L62) | PubSub topic name. | string | ✓ | |
-| [project_id](variables.tf#L67) | Project used for resources. | string | ✓ | |
+| [name](variables.tf#L68) | PubSub topic name. | string | ✓ | |
+| [project_id](variables.tf#L73) | Project used for resources. | string | ✓ | |
| [dead_letter_configs](variables.tf#L17) | Per-subscription dead letter policy configuration. | map(object({…})) | | {} |
| [defaults](variables.tf#L26) | Subscription defaults for options. | object({…}) | | {…} |
| [iam](variables.tf#L44) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} |
| [kms_key](variables.tf#L50) | KMS customer managed encryption key. | string | | null |
| [labels](variables.tf#L56) | Labels. | map(string) | | {} |
-| [push_configs](variables.tf#L72) | Push subscription configurations. | map(object({…})) | | {} |
-| [regions](variables.tf#L85) | List of regions used to set persistence policy. | list(string) | | [] |
-| [subscription_iam](variables.tf#L91) | IAM bindings for subscriptions in {SUBSCRIPTION => {ROLE => [MEMBERS]}} format. | map(map(list(string))) | | {} |
-| [subscriptions](variables.tf#L97) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | map(object({…})) | | {} |
+| [message_retention_duration](variables.tf#L62) | Minimum duration to retain a message after it is published to the topic. | string | | null |
+| [push_configs](variables.tf#L78) | Push subscription configurations. | map(object({…})) | | {} |
+| [regions](variables.tf#L91) | List of regions used to set persistence policy. | list(string) | | [] |
+| [subscription_iam](variables.tf#L97) | IAM bindings for subscriptions in {SUBSCRIPTION => {ROLE => [MEMBERS]}} format. | map(map(list(string))) | | {} |
+| [subscriptions](variables.tf#L103) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | map(object({…})) | | {} |
## Outputs
diff --git a/modules/pubsub/main.tf b/modules/pubsub/main.tf
index af08de389..2645de023 100644
--- a/modules/pubsub/main.tf
+++ b/modules/pubsub/main.tf
@@ -36,10 +36,11 @@ locals {
}
resource "google_pubsub_topic" "default" {
- project = var.project_id
- name = var.name
- kms_key_name = var.kms_key
- labels = var.labels
+ project = var.project_id
+ name = var.name
+ kms_key_name = var.kms_key
+ labels = var.labels
+ message_retention_duration = var.message_retention_duration
dynamic "message_storage_policy" {
for_each = length(var.regions) > 0 ? [var.regions] : []
diff --git a/modules/pubsub/variables.tf b/modules/pubsub/variables.tf
index 592d80090..009a12fbe 100644
--- a/modules/pubsub/variables.tf
+++ b/modules/pubsub/variables.tf
@@ -59,6 +59,12 @@ variable "labels" {
default = {}
}
+variable "message_retention_duration" {
+ description = "Minimum duration to retain a message after it is published to the topic."
+ type = string
+ default = null
+}
+
variable "name" {
description = "PubSub topic name."
type = string