google-cloud-platformgoogle-cloud-functionspublish-subscribegoogle-cloud-pubsubgoogle-deployment-manager

How to set pubsub message filter while creating cloud-function with triggerTopic


I was trying to create a google cloud function which can be triggered by a pubsub topic. I used the google deployment manager template for creating it. But I couldn't find any way to set the subscriber message filter for that cloud function. I tried to create the subscription before and after the cloud function resource was created. But in no ways it worked. If I create it before creating cloud function then after the resource is created it overrides the subscriber function and removes the filter.

Is it possible to set subscriber message filter for any pubsub cloud function using google deployment manager template?


Solution

  • In fact, it's not possible at all. When you deploy a Cloud functions in mode trigger-topic, you can't set a filter on the subscription (which is automatically created). And it's not a limitation of deployment manager.

    If you want to trigger a Cloud Function on a PubSub message with the filter activated, you need to