The initial question was asking about permissions, but I can only see answers listing roles and there is a difference between roles and permissions. For the sake of future visitors (like me :) ) I will add an additional command.
Explanation of the difference:
Permissions in GCP are allowing access to the specific type of the resource and role is a group of such permissions.
e.g. Editor role has all the permissions that Viewer role has and also additional ones allowing to manage networking, instances,etc.
compute.instances.create
is a permission allowing to create an instance.
roles/Editor
is a role containing this permission. Assigning role gives a permission for the user to the resource.
Solution:
Listing roles can be done by commands mentioned by Jelle den Burger or ingernet ( gcloud projects get-ancestors-iam-policy <project-id>
), but if you want to know more specifically what kind of permissions does the user have, you need to dig deeper. With my short research, I was able to find only this command describing what permissions does a role contain:
gcloud iam roles describe [ROLE]
example gcloud iam roles describe roles/spanner.databaseAdmin
So you would have to write a short shell script to connect those two commands, first one listing user roles, second one listing permissions of the roles. The outcome will be a list of permissions user has.