Reputation: 1803
I have a pub/sub topic in project A. I would now like to stream messages from that topic into a dataflow pipeline running in a different project B. I have followed the example at https://cloud.google.com/pubsub/docs/stream-messages-dataflow and everything works when the topic is in the same project as the dataflow pipeline. However, when trying to stream messages from a topic in a different project I get the following permissions error:
INFO:apache_beam.runners.dataflow.dataflow_runner:2022-11-09T16:34:40.349Z: JOB_MESSAGE_ERROR: Workflow failed. Causes: Check if topic projects/XXXXXXX/topics/test-topic exists failed with error: User not authorized to perform this action.
The service account which runs the pipeline has the Pub/Sub Admin role in both projects. I even tried making it Owner in project A (where the topic lives), but no success. I always get the same error.
Upvotes: 0
Views: 609
Reputation: 6572
To solve this issue :
Dataflow
job in the project BIAM
menu of projet A, give the permissions to read from the Pub Sub
in the projet AIAM
menu of projet B, give the permissions to launch a Dataflow
job in the project BDataflow
job in the project B, set a program argument indicating what Service Account email launches the job :For Dataflow
Python
:
--service_account_email=my-service-account-name@<project-id>.iam.gserviceaccount.com
For Dataflow
Java
:
--serviceAccount=my-service-account-name@<project-id>.iam.gserviceaccount.com
Upvotes: 0
Reputation: 2725
You might need to create a subscription in the source project (A), so your dataflow job (in the project B) takes the messages from that subscription (from the project A).
Then yoou find out a service account under which your dataflow job is runnig (in the project B). Presumably that service account is in the project B. And provide relevant permissions to that service account, so it can work with the source subscription (from the project A).
Upvotes: 1