Reputation: 9193
I am trying to achieve the following on gcp using terraform.
I'm not sure how to create the subscription for the cloud function which also contains the dead letter policy. At the moment I'm doing the following for the cloud function,
resource "google_cloudfunctions_function" "brw-user-function-item-registered" {
// details
event_trigger {
event_type = "google.pubsub.topic.publish"
resource = "brw-messages"
failure_policy {
retry = false
}
}
// details
}
However there is no option to specify the dead-letter policy in the event_trigger
section. If I create a separate google_pubsub_subscription
I'm not sure how to give the endpoint to the cloud function. I had a look at what gets created and its actually an endpoint, however I'm not sure how to specify those details in the google_pubsub_subscription
Upvotes: 1
Views: 2098
Reputation: 75735
You can't plug a function directly on a PubSub topic and define a deadletter topic. (same issue if you want to define filters on your subscription).
The solution is to create an HTTP functions, and to create separately a push subscription with a dead letter topic. 2 points of attention:
In addition, keep in mind that the dead letter topic is used when at least 5 failures occur on the same message. The dead letter topic is not used at the first error returned by your Cloud Functions.
Upvotes: 3