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 role.

$ gcloud projects get-iam-policy MY_PROJECT

- members:
  - serviceAccount:[email protected]
  - user:[email protected]
  role: roles/editor
- members:
  - user:[email protected]
  - user:[email protected]
  role: roles/owner
version: 1

What's the --filter= expression that I need to use to list only users with the role roles/owner?

  • I have a similar question but I want to filter by member-name. The --query thing does not help
    – KargWare
    Commented Jun 22, 2021 at 12:02

2 Answers 2


That can be achieved using another gcloud command:

gcloud beta asset search-all-iam-policies --query policy:"roles/owner" --project $your_project_id --flatten="results[].policy[]" --format="csv(bindings.members[0])"

Ran into this requirement recently as well. You can achieve this without the use of the assets API.

$ gcloud projects get-iam-policy $PROJECT --flatten="bindings[].members" --filter="bindings.role:roles/owner" --format='table(bindings.members)'

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.