Reputation: 19995
I want to run Dataflow jobs with a per job dedicated custom service account.
Upon creation, the Dataflow job wants to create a new Pub/Sub subscription, on deployment, to use as the watermark tracking subscription. It has the form of <SOURCE_SUB_NAME>__df_internal<HASH>
where SOURCE_SUB_NAME
is the actual subscription that the Dataflow pipeline has been configured to pull data from.
My question is how this can be done under the Principle of Least Privilege using a custom service account for this specific Dataflow job. Since the job needs to create a copy of the source Pub/Sub subscription, it needs to make a new subscription on the Pub/Sub topic which feeds source subscription. However, even if I grant the job service account the roles/pubsub.subscriber
OR roles/pubsub.editor
on the topic in question, I still get 403 errors in the pipeline, trying to call the Subscriber.CreateSubscription
API endpoint. Empirically, I found I could only get Dataflow to make the new tracking subscription if I granted roles/pubsub.editor
against the entire GCP project.
Given that, how can you use PLP without making your Dataflow job a Pub/Sub Editor on the entire GCP project? Being a project wide Pub/Sub editor means your job could read from any other topic, thus giving it more potential data access than necessary for a given job.
Upvotes: 0
Views: 52
Reputation: 75950
You have to use 2 custom roles.:
pubsub.subscriptions.create
, the pubsub.subscriptions.get
, pubsub.subscriptions.list
, pubsub.subscriptions.update
could be required, I don't know exact how work your dataflow pipelinepubsub.topics.attachSubscription
With this 2 created, you have to grant your Dataflow Service Account like this:
By doing this, your dataflow can create multiple subscription, but can attach it only on the authorized topic, not on other. No data leakage like this.
Upvotes: 0
Reputation: 153
The error 403 refers to the incorrect IAM permission and as for your project, my insight is make a custom role with the permission only necessary to create and manage subscription (not the roles/pubsub.editor
). After that, assign that custom role at the topic level (roles/pubsub.subscriber
) and this will follow the PLP and avoid granting unnecessary permission.
Upvotes: 0