Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set access permissions of google cloud storage bucket folder

How do I set access permissions for entire folder in storage bucket? Example; I have 2 folders (containing many subfolders/objects) in single bucket (let's call them folder 'A' and 'B') and 4 members in project team. All 4 members can have read/edit access for folder A but only 2 of the members are allowed to have access to folder 'B'. Is there a simple way to set these permissions for each folder? There are hundreds/thousands of files within each folder and it would be very time consuming to set permissions for each individual file. Thanks for any help.

like image 895
G Lee Avatar asked Jul 25 '16 18:07

G Lee


People also ask

How do I grant access to the Google Cloud storage bucket?

In the Google Cloud console, go to the Cloud Storage Buckets page. Click the Bucket overflow menu ( ) associated with the bucket to which you want to grant a principal a role. Choose Edit access.

How do I change permissions on Google cloud?

In the Google Cloud console, go to the Manage resources page. Select all the resources for which you want to grant permissions.


2 Answers

It's very poorly documented, but search for "folder" in the gsutil acl ch manpage:

Grant the user with the specified canonical ID READ access to all objects in example-bucket that begin with folder/:

gsutil acl ch -r \
  -u 84fac329bceSAMPLE777d5d22b8SAMPLE785ac2SAMPLE2dfcf7c4adf34da46:R \
  gs://example-bucket/folder/
like image 96
carillonator Avatar answered Sep 18 '22 12:09

carillonator


It looks like this has become possible through IAM Conditions.

You need to set a IAM Condition like: resource.name.startsWith('projects/_/buckets/[BUCKET_NAME]/objects/[OBJECT_PREFIX]')

There are some limitations here, such as no longer being able to use the gsutil acl ch commands referenced in other answers.

like image 41
John Donahue Avatar answered Sep 21 '22 12:09

John Donahue