Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deadLetterPolicy to Pub/Sub Subscription resource #3305

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions products/pubsub/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,45 @@ objects:
If ttl is not set, the associated resource never expires.
A duration in seconds with up to nine fractional digits, terminated by 's'.
Example - "3.5s".
- !ruby/object:Api::Type::NestedObject
name: 'deadLetterPolicy'
send_empty_value: true
description: |
A policy that specifies the conditions for dead lettering messages in
this subscription. If dead_letter_policy is not set, dead lettering
is disabled.

The Cloud Pub/Sub service account associated with this subscriptions's
parent project (i.e.,
service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
permission to Acknowledge() messages on this subscription.
properties:
- !ruby/object:Api::Type::String
name: 'deadLetterTopic'
description: |
The name of the topic to which dead letter messages should be published.
Format is `projects/{project}/topics/{topic}`.

The Cloud Pub/Sub service\naccount associated with the enclosing subscription's
parent project (i.e.,
service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
permission to Publish() to this topic.

The operation will fail if the topic does not exist.
Users should ensure that there is a subscription attached to this topic
since messages published to a topic with no subscriptions are lost.
- !ruby/object:Api::Type::Integer
name: 'maxDeliveryAttempts'
description: |
The maximum number of delivery attempts for any message. The value must be
between 5 and 100.

The number of delivery attempts is defined as 1 + (the sum of number of
NACKs and number of times the acknowledgement deadline has been exceeded for the message).

A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
client libraries may automatically extend ack_deadlines.

This field will be honored on a best effort basis.

If this parameter is 0, a default value of 5 is used.
6 changes: 6 additions & 0 deletions products/pubsub/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
topic_project: "topic-project"
subscription_name: "example-subscription"
subscription_project: "subscription-project"
- !ruby/object:Provider::Terraform::Examples
name: "pubsub_subscription_dead_letter"
primary_resource_id: "example"
vars:
topic_name: "example-topic"
subscription_name: "example-subscription"
docs: !ruby/object:Provider::Terraform::Docs
attributes: |
* `path`: Path of the subscription in the format `projects/{project}/subscriptions/{name}`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['topic_name'] %>"
}

resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>_dead_letter" {
name = "<%= ctx[:vars]['topic_name'] %>-dead-letter"
}

resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['subscription_name'] %>"
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name

dead_letter_policy {
dead_letter_topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>_dead_letter.id
max_delivery_attempts = 10
}
}