I have used the sample code in the GCP guide https://cloud.google.com/billing/docs/how-to/notify to create a Python Cloud Function to send out messages and disable billing for a project whenever a budget alert indicates that the project is exceeding a spend limit. The budget alert uses pubsub to activate the Cloud Function.
Using the sample code approach the Cloud Function is within the project being monitored. The project is owned by a specific Google account and it is the same Google account that owns the budget that uses pubsub when a budget alert is issued.
I would like to provide the Cloud Function to other Google accounts as a service. What I want to happen is when a budget alert is triggered in a Google account other than my own then a pubsub message is sent to a Cloud Function of one of my projects under my Google account.
It seems to me that this is what pubsub is for but whenever I try to configure this approach I find that the only combination I can get to work is where the budget and Cloud Function are under the same Google account.
I wonder if the solution is to be found in IAM and setting up an Organization structure. I am finding it difficult to get to grips with IAM. Any suggestions gratefully received, even a "this is not possible" would be helpful.
Thanks