Status Update
Comments
ya...@google.com <ya...@google.com>
po...@gmail.com <po...@gmail.com> #2
mp...@google.com <mp...@google.com> #3
Please also follow this public issue tracker:
ja...@gmail.com <ja...@gmail.com> #4
Although these are workable, none of these solutions offer a non-public serverless approach to solving this problem. Running a GCE node or streaming job is a few thousand dollars per year in the Australian region, or the push requires more project coupling and a public end point.
pa...@axa.ch <pa...@axa.ch> #5
li...@liveramp.com <li...@liveramp.com> #6
ch...@gmail.com <ch...@gmail.com> #7
da...@gmail.com <da...@gmail.com> #8
lg...@google.com <lg...@google.com> #9
so...@google.com <so...@google.com> #10
Also, curious how other customers are solving this problem currently? Is there a workaround that our customers can use?
ro...@sulamerica.com.br <ro...@sulamerica.com.br> #12
Thats works for a cross project approach. FYI
rm...@google.com <rm...@google.com> #13
A workaround for this is to use a Pub/Sub push subscription that invokes your Cloud Function over HTTP. This is the officially supported way of doing it.
This is essentially what is being set up a function is created with a Cloud Storage bucket trigger.
ProjectA
- where the Cloud Function resides, NOT the Cloud Storage bucket we wish to see notifications fromFunctionA
- function handling the bucket notificationsProjectB
- where the bucket, Pub/Sub topic and Pub/Sub subscription resideBucketB
- bucket NOT inProjectA
that we want to have events invokeFunctionA
SubscriptionB
- push subscription used to pass bucket changes to an HTTP endpoint (FunctionA
)TopicB
- topic where messages about changes toBucketB
goServiceaccountB
- service account configured inTopicB
that has permissions to invokeFunctionA
inProjectA
ProjectA
: Configure the Cloud Function
- create
FunctionA
- make sure
FunctionA
is HTTP invokable - grant permissions for a service account in
ProjectB
to invoke the function by adding it as a principal under Permissions in theFunctionA
config (egServiceaccountB@projectb.iam.gserviceaccount.com
) - get the HTTP trigger of
FunctionA
under the Trigger tabhttps://us-central1-projecta.cloudfunctions.net/FunctionA
- save it
ProjectB
: Create Pub/Sub TopicB and enable notifications
- create
TopicB
- enable notifications on the bucket using
gsutil notification create -t TopicB -f json gs://BucketB
ProjectB
: Create a push subscription on TopicB
- create
SubscriptionB
- set the push target at
https://us-central1-projecta.cloudfunctions.net/FunctionA
- enable authentication and set it as
ServiceaccountB@projectb.iam.gserviceaccount.com
- save
SubscriptionB
Test by writing an object to BucketB
, you should see invocations in the logs for FunctionA
, or you will see Pub/Sub errors on SubscriptionB
in ProjectB
. The body of the POST to FunctionA
will be data from the bucket.
The implementation of this feature is infeasible given the architecture of GCP and the way that the Cloud Function creation UI works, in that it needs to populate options by iterating all IAM allowed projects. It may be possible to add an entry field and verify later, but this is not part of the current product roadmap.
rm...@google.com <rm...@google.com> #14
An update here; the product team would like to keep this open for consideration as they do believe it's something worth solving. However, we don't have a timeline for this, it is advised to use the workaround mentioned in the previous comment for the time being.
[Deleted User] <[Deleted User]> #15
br...@richemont.com <br...@richemont.com> #16
We are using GCP in an very large enterprise context and we definitely need to have this limitation solved in a cloud native way. It would be a pity to install messaging services like rabbitmq because we cannot cover this use case when multiple GCP projects need to communicate with one another.
This issue has been opened four years ago. Could you not share what is your priority compared to all other tickets?
If PubSub is meant to be used as "global" messaging, this is a must-have feature.
er...@dv01.co <er...@dv01.co> #17
Has there been any update on this? We're encountering the same issue now where we want to have all of our topics/subscriptions live inside a single project and have cloud functions trigger in a separate project. Adding an intermediary listener adds extra complexity and managerial overhead to this ask which is why we started using cloud functions in the first place.
es...@google.com <es...@google.com> #18
+1'ing from Cloud Marketplace. Our 3rd party SaaS partners need to integrate with Pub/Sub topics from a Google-owned project (
ad...@quantummetric.com <ad...@quantummetric.com> #19
We ran into this while implementing Cloud Marketplace integration, as mentioned. We needed the extra push subscription to make it work. More moving parts to build, maintain and explain to others. Google-owned topic direct to Cloud Function would certainly make an all-Google solution feel streamlined.
rp...@ford.com <rp...@ford.com> #20
om...@vodafone.com <om...@vodafone.com> #21
We are in similar situation with 'answer #16', this workaround is not feasible within our organization. Please can you provide timeline for this as cloud native solution of this is crucial for us?
dh...@gmail.com <dh...@gmail.com> #22
Here is the solution: Pub/Sub — Push Messages to Cloud Function Endpoint in a different GCP Project
Step 1: Ensure In API and services , Pub/Sub API is enabled
Step 2: In Project A, Go to Pub/Sub then create a pubsub topic from GUI by providing the topic ID as required with default settings (In projectA created topic projects/projectid/topics/dhanatest) and here is how we create topic from UI:
Step 3:In Project B, create a basic cloud function in python of 1st gen with http trigger (check Require https) and here is attached cloud function(function-dp) code I used in Project-- B and in the service account in Runtime , please give service account which has roles Cloud Functions Invoker, Pub/Sub Publisher, Pub/Sub Subscriber, Logging Admin () and Go to Cloud Functions from search UI and below is how to create simple cloud function from UI:
Step 4:
4a) Create a push subscription in Project B taking Project A’s topic from UI and click on Enable Authentication.
4b) After clicking Enable Authentication , It asks for Endpoint Url and service account ,so In Endpoint Url , Give https url from cloud function and for service account , give service account with roles Cloud Functions Invoker, Pub/Sub Publisher, Pub/Sub Subscriber, Logging Admin, leave remaining fields default and click on create to create subscription
Step 5:Now, Publish message from Project A and see the cloud function logs, We should see Function executed successfully with return code:200
Note:We can do the above thing not only from UI , we can do from Python code also to creaste subscriptionand here is the attached code, we can run from cloud shell the python file.
br...@gmail.com <br...@gmail.com> #23
Has anyone succeeded by using eventarc? Push subscription is not allowed in VPC controlled projects so the workaround is not feasible for us.
Description
There are some workarounds. But currently there is no way to do that directly.