Cloud Function triggered by PubSub topic in another project

3,902 views
Skip to first unread message

Joshua Fox

unread,
Jul 30, 2019, 2:56:17 AM7/30/19
to Google Cloud Pub/Sub Discussions
I would like my My Cloud  Function in Project A to be triggered by PubSub topic from Project B.

I specify the topic with --trigger-topic mytopic in deployment but I would like somehow  to specify that mytopic is in project-b.

Outside Cloud Functions, I know how to access PubSub cross-project, for example in Python with  publisher_client.create_topic('projects/project-b/topics/mytopic') (and  loading appropriate Google Application Credentials).

How do I access a  cross-project topic from Cloud Functions?

Ali At Tayeb

unread,
Jul 30, 2019, 10:07:12 AM7/30/19
to Google Cloud Pub/Sub Discussions
Hi,

As per the Cloud Functions Pub/Sub trigger documentation, the function can only be triggered by messages published to a topic in the same GCP project as the function. 

There is an open feature request to have this functionality added to Cloud Functions. You can also find a workaround using an HTTP-function described in this StackOverflow answer. 

Kir Titievsky

unread,
Jul 30, 2019, 10:09:54 AM7/30/19
to Joshua Fox, Google Cloud Pub/Sub Discussions
You can't today. Sorry.  We are working to make this possible within a couple months.  You could solve this for now by having a relay layer: your producers might read from project-specific topics and republish all the data all to a single topic in a single project.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/CAD%3DB7cNBWn4EZH-c7Xx486y_q%2BVz2LKS1SmWpiefGfZx-VbHVw%40mail.gmail.com.


--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

Eric Park

unread,
Dec 7, 2021, 4:14:44 PM12/7/21
to pubsub-discuss

Hi,

Is there an update on this? We're looking to create a Cloud Function with a Pub/Sub topic in a separate project. 
Please advise!

Thank you,
Eric Park

dikaur

unread,
Dec 8, 2021, 4:16:07 PM12/8/21
to pubsub-discuss
Hello Erik,

The functionality to create Cloud Function with a Pub/Sub topic in a separate project is not yet available. You can see the feature request [1], in which several workarounds are also included that might be useful for your environment. Any updates regarding the feature request will also be posted under the same PIT [1]. Please be sure to star [2] the issue to receive notification on any updates. 

Kir Titievsky

unread,
Dec 9, 2021, 9:55:23 AM12/9/21
to dikaur, pubsub-discuss
Eric, I'm trying to track down the right people in cloud functions to see if we can give you a view as to when this might happen. 

You received this message because you are subscribed to the Google Groups "pubsub-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages