So, I want to grant a user to access a folder in a bucket.
So a user with user-id `A` can access <bucket>/<folder for storing>/<user-id>/
So, the requirement
Through this IAM condition documentation, I can achieve requirements 1 and 2.
Additional permissions required to list objects in this bucket. Ask a bucket owner to grant you 'storage.objects.list' permission.
But, user can upload the files, and reupload the file if user knows the exact name.
Point to note
I have tried to look on the documentation, but I haven't get the answer.
Solved! Go to Solution.
As mentioned at documentation:
"
storage.objects.list
permission is granted at the bucket level, you cannot use the resource.name
condition attribute to restrict object listing access to a subset of objects in the bucket. Users without storage.objects.list
permission at the bucket level can experience degraded functionality for the Console and gsutil."
Following least privilege principle I'd recommend to assign storage/objectViewer at bucket level for your users accounts.
For testing the results I'd recommend to run gsutil ls gs://<bucket_name>/<folder for storing>/<user-id>/ as the user you want to have access to the bucket [1]. Then you should be able to list the folder's content.
As well you should be able to list the folder content within Cloud Console UI.