1

gcloud projects get-iam-policy [PROJECT-ID] lists all users with their roles for specific project.

There are different filters and formatters available but I can't seem to find the right way to just filter only by specific user.

HINT: I reused the example code of DevOps - How to list all users with specific role in GCP

$ gcloud projects get-iam-policy MY_PROJECT

bindings:
- members:
  - serviceAccount:[email protected]
  - user:[email protected]
  role: roles/editor
- members:
  - serviceAccount:[email protected]
  role: roles/pubsub.serviceAgent
- members:
  - user:[email protected]
  - user:[email protected]
  role: roles/owner
etag: ARBITRARY_ETAG_HERE
version: 1

What's the --filter= expression that I need to use to list only items with the members - serviceAccount:[email protected]?

1 Answer 1

1

After a bit more googling, I found that post.

Sorry!

Here is the solution which works for me

gcloud projects get-iam-policy MY_PROJECT --format='table(bindings.role)' --filter="bindings.members:serviceAccount:[email protected]"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.