Skip to content

Instantly share code, notes, and snippets.

@manasouza
Last active September 25, 2019 18:34
Show Gist options
  • Select an option

  • Save manasouza/8568fde37d8824c56de9583c5cd406fa to your computer and use it in GitHub Desktop.

Select an option

Save manasouza/8568fde37d8824c56de9583c5cd406fa to your computer and use it in GitHub Desktop.
GCP SDK Shell Scripts Utils

Google Cloud SDK Utility Commands

List all IAM roles applicable for a specific IAM permission

# any permission listed at https://cloud.google.com/iam/docs/permissions-reference
export expected_permission=<permission>

for role in $(gcloud iam roles list --format='value(NAME)');                                     
do permissions=$(gcloud iam roles describe $role --format='value(includedPermissions)')
if [[ $permissions =~ $expected_permission  ]]; then echo "-------------------------------------------------" &&  echo $role && echo "-------------------------------------------------"; fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment