Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-pubsub

Cloud function is not triggered by pub/sub topic


I have several cloud functions running in my GCP project which are connected to a pub/sub topic. They all subscribe to a different topic.

When starting the function, I can see a subscription is created on the topic and when sending messages the pub/sub topic is receiving them. However, the corresponding cloud functions are not triggered and are not processing the messages. I can see the unacked message count on the subscription increasing so until the subscription everything seems to be working fine.

I am talking here about my production environment. I have this exact same setup in my development project, where it's working seamlessly. The only difference is that I am assigning a specific service account to the functions in the production environment. But I believe that if the service account was the issue, there would already be an error when deploying the function.

Does anyone have advice on how to debug and solve this?

Thanks!


Solution

  • I was able to solve this, using this link: https://www.googlecloudcommunity.com/gc/Serverless/Cloud-Function-2nd-gen-cant-hit-cloud-run-deployed-by-them/m-p/625594

    I had to add the Cloud Run Invoker role to my service account that was attached to the Cloud Function.