The command gsutil ls
lists the buckets in your project.
To list buckets you need the permission storage.buckets.list
.
To list the objects in a bucket you need the permission storage.objects.list
.
Neither of those permissions allows you to read an object. To read an object you need the permission storage.objects.get
.
To only read an object, you do not need the list permissions. However, since you are using the gsutil
command, you do.
There are several predefined roles that you can attach to your service account to grant the necessary permissions for gsutil
.
Recommended:
roles/storage.objectViewer
Or the following two roles:
roles/storage.legacyObjectReader
roles/storage.legacyBucketReader
If you ONLY want to assign a role to read an object but not list them:
roles/storage.legacyObjectReader