0
votes

Is there a way to define an IAM policy or custom role to allow access to certain cloud storage buckets for a project instead of having to add the user for each individual bucket?

1
Edit your question and include details on how you have access control configured for the bucket. cloud.google.com/storage/docs/access-control - John Hanley

1 Answers

0
votes

Create a custom role as per your requirement and write a shell script to grant a role to a member.

Example -

  #!/bin/bash
  members=(member1 member2 member3)
  for i in “${members[@]}”
  do 
        gcloud projects add-iam-policy-binding my-project \
        --member=user:$i --role=role-id 
  done

The above script will bind the role to members.

gcloud command -

gcloud group add-iam-policy-binding resource \
    --member=member --role=role-id 
  • Group: The gcloud tool group for the resource you want to update. For example, you can use projects or organizations.

  • resource: The name of the resource.

  • Member: An identifier for the member, An identifier for the member, For example, user:[email protected]/.