Search code examples
google-cloud-platformterraformgoogle-cloud-pubsub

How to make a PubSub triggered Cloud Function with message ordering using terraform?


I am trying to create a Cloud Function that is triggered from a PubSub subscription, but I need to have the message ordering enabled. I know to use the event_trigger block in the google_cloudfunctions_function block, when creating a function linked to a subscription. However this does not like the enable_message_ordering as described under PubSub. When using the subscription push config, I don't know how I can get link the endpoint to the function.

So is there a way I can link the function to a subscription with message ordering enabled? Can I just use the internal URL to the function as the push config URL?


Solution

  • You can't use background functions triggered by PubSub and message ordering (or filtering).

    You have do deploy a HTTP functions (take care, the signature of the fonction change, and the the format of the PubSub message also change slightly).

    Then create a PubSub PUSH subscriptions, use the Cloud Functions URL. The best is also to add a Service Account on PubSub to allow only it to call your Functions.