Permissions error with Apache Beam example on Google Dataflow

Viewed 5880

I'm having trouble submitting an Apache Beam example from a local machine to our cloud platform.

Using gcloud auth list I can see that the correct account is currently active. I can use gsutil and the web client to interact with the file system. I can use the cloud shell to run pipelines through the python REPL.

But when I try and run the python wordcount example I get the following error:

IOError: Could not upload to GCS path gs://my_bucket/tmp: access denied.
Please verify that credentials are valid and that you have write access 
to the specified path.

Is there something I am missing with regards to the credentials?

6 Answers

I have faced the same issue where it throws up the IO error. Things that helped me here are (not in the order):

  1. Checking the Name of the bucket. This step helped me a lot. Bucket names are global. If you make mistake in the bucket-name while accessing your bucket then you might be accessing buckets that you have NOT created and you don't have permission to.

  2. Checking the service account that you have filled in:

    • export GOOGLE_CLOUD_PROJECT= yourkeyfile.json

Activating the service account for the key file you have plugged in -

gcloud auth activate-service-account --key-file=your-key-file.json 

Also, listing out the auth accounts available might help you too.

gcloud auth list

One solution might work for you. It did for me.

In the cloud shell window, click on "Launch code Editor" (The Pencil Icon). The editor will work in Chrome (not sure about Firefox), it did not work in Brave browser.

Now, browse to your code file [in the launched code editor on GCP] (.py or .java) and locate the pre-defined PROJECT and BUCKET names and replace the name with your own Project and Bucket names and save it.

Now execute the file and it should work now.

Python doesn't use gcloud auth to authenticate but it uses the environment variable GOOGLE_APPLICATION_CREDENTIALS. So before you run the python command to launch the Dataflow job, you will need to set that environment variable:

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key"

More info on setting up the environment variable: https://cloud.google.com/docs/authentication/getting-started#setting_the_environment_variable

Then you'll have to make sure that the account you set up has the necessary permissions in your GCP project.

Permissions and service accounts:

Related