Permissions Error Exporting a table from Google BigQuery to Google Cloud Storage

Viewed 6491

Getting the following error as of 2017-07-08 when exporting a table to Cloud Storage.

Access Denied: BigQuery BigQuery: Permission denied while writing data

Working fine before that date, haven't changed anything in the project, big query or cloud storage.

JobId: alert-basis-89415:bquijob_6adfd86e_15d2de5ce1b

6 Answers

I was getting a similar error. It was because I was using a bucket in region different from the BQ dataset, and a incorrect bucket URL. After I ensured following two

  • I double checked and fixed specified bucket URL is correct
  • I created bucket in same region that the data resides

I was good

Look up the service account's e-mail address, and add the account to the bucket ACL as a writer and file reader:

gsutil acl ch -u blabla@project.iam.gserviceaccount.com:W gs://bucket
gsutil acl ch -u blabla@project.iam.gserviceaccount.com:R gs://bucket/1.csv
gsutil acl ch -u blabla@project.iam.gserviceaccount.com:R gs://bucket/2.csv

Make sure the service account has the right permissions to do things on that bucket. It's confusing because even if the bucket is public, that doesn't allow write access from just plain old anyone.

I had the same error. All my IAM grants looked correct.

It turns out it was failing because the SA has permission to create files (object.Creator) but not to overwrite/replace files in the bucket. Because a file by the same name already existed in the bucket it failed until I removed the file (or you can give it permission to overwrite the file).

The error is confusing/misleading though.

Access Denied: BigQuery BigQuery: Permission denied while writing data."

Using bq cli to show the job details was helpful in debugging this issue.

bq show --format=prettyjson --job=true <<job-id>>

It was a problem on Google's end. I found a topic in Google groups (can't seem to find it now) where you could supply your details and they applied a hotfix for those accounts before rolling it out proper.

Related