I have created a service account and given it only the Storage Object Viewer
role. I would like to use this service account to download objects from a bucket using the python API.
I have set the GOOGLE_APPLICATION_CREDENTIALS
environment variable accordingly and can see the relevant service account showing up on the bucket's permissions page.
I use the following code to try and download an object
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket(BUCKET_NAME)
But I get the following error when calling get_bucket
google.api_core.exceptions.Forbidden:
403 GET https://storage.googleapis.com/storage/v1/b/samplereadbucket?projection=noAcl:
sample-service-account@project.iam.gserviceaccount.com does not have storage.buckets.get
access to samplereadbucket.
What is the minimum set of roles I need to set so that the service account has storage.buckets.get
access if not Storage Object Viewer
?