Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I grant individual permissions in Google Cloud Platform for BigQuery users

I need to setup very fine-grained access control for service accounts in GCP. I am seeing this error:

"user SERVICE_ACCOUNT does not have bigquery.jobs.create permission in project PROJECT_ID".

I know that via UI/gcloud util I can give it role roles/bigquery. user, but it has a lot of other permissions I don't want this service account to have.

How can I grant individual permissions via gcloud/UI or some other means?

like image 596
yura Avatar asked Mar 03 '17 01:03

yura


People also ask

How do you grant permissions in BigQuery?

Granting access to a datasetIn the Explorer panel, expand your project and select a dataset. In the details panel, click Sharing > Permissions. Click Add principal. In the New principals field, enter the entity that you want to add.

What is Google Cloud's principle for granting access to users?

IAM lets you grant granular access to specific Google Cloud resources and helps prevent access to other resources. IAM lets you adopt the security principle of least privilege, which states that nobody should have more permissions than they actually need.


2 Answers

You can use Custom Roles, visible in the IAM section:

enter image description here

Create a role with the specific mix of permissions you need. Then it will appear in 'Custom' on the IAM role assignment page and will be available via the API.

For your specific use case, try the following in your custom role:

  • bigquery.jobs.create
  • bigquery.jobs.get
  • bigquery.tables.create
  • bigquery.tables.update
like image 129
Paul Kenjora Avatar answered Oct 16 '22 19:10

Paul Kenjora


You can configure IAM directly in the Google Cloud Console:

https://console.cloud.google.com/iam-admin/iam/

Service accounts are designed to be used for server side applications e.g. VMs, AppEngine etc. In other words:

[It's] an account that belongs to your application instead of to an individual end user. Your application calls Google APIs on behalf of the service account, so users aren't directly involved.

https://developers.google.com/identity/protocols/OAuth2ServiceAccount

The service account can have different BigQuery IAM roles assigned to it via the console, like so:enter image description here

You add also add individual users (emails backed by a Google account) to IAM using the console, and then select which permissions they individually should have in BigQuery, like so: enter image description here

BigQuery permissions & roles are defined here.enter image description here

like image 37
Graham Polley Avatar answered Oct 16 '22 19:10

Graham Polley