Skip to content

Commit

Permalink
feat: Adding support for retry_policy.maximum_backoff and retry_polic…
Browse files Browse the repository at this point in the history
…y.minimum_backoff (#40)

Co-authored-by: Mehdi Karamosly <[email protected]>
  • Loading branch information
mkaramosly and Mehdi Karamosly authored Nov 11, 2020
1 parent 3365311 commit 4972a25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module "pubsub" {
expiration_policy = "1209600s" // optional
dead_letter_topic = "example-dl-topic" // optional
max_delivery_attempts = 5 // optional
maximum_backoff = "600s" // optional
minimum_backoff = "300s" // optional
}
]
pull_subscriptions = [
Expand All @@ -37,6 +39,8 @@ module "pubsub" {
ack_deadline_seconds = 20 // optional
dead_letter_topic = "example-dl-topic" // optional
max_delivery_attempts = 5 // optional
maximum_backoff = "600s" // optional
minimum_backoff = "300s" // optional
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ resource "google_pubsub_subscription" "push_subscriptions" {
}
}

dynamic "retry_policy" {
for_each = (lookup(var.push_subscriptions[count.index], "maximum_backoff", "") != "") ? [var.push_subscriptions[count.index].maximum_backoff] : []
content {
maximum_backoff = lookup(var.push_subscriptions[count.index], "maximum_backoff", "")
minimum_backoff = lookup(var.push_subscriptions[count.index], "minimum_backoff", "")
}
}

push_config {
push_endpoint = var.push_subscriptions[count.index]["push_endpoint"]

Expand Down Expand Up @@ -170,6 +178,14 @@ resource "google_pubsub_subscription" "pull_subscriptions" {
}
}

dynamic "retry_policy" {
for_each = (lookup(var.pull_subscriptions[count.index], "maximum_backoff", "") != "") ? [var.pull_subscriptions[count.index].maximum_backoff] : []
content {
maximum_backoff = lookup(var.pull_subscriptions[count.index], "maximum_backoff", "")
minimum_backoff = lookup(var.pull_subscriptions[count.index], "minimum_backoff", "")
}
}

depends_on = [
google_pubsub_topic.topic,
]
Expand Down

0 comments on commit 4972a25

Please sign in to comment.