-
-
Save rizkylab/598e31cdd60ee953cb10646d8956c41c to your computer and use it in GitHub Desktop.
Script to retrieve GCP IAM roles, users and serviceaccounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to retrieve GCP IAM roles, users and serviceaccounts | |
# Author - Rajathithan Rajasekar - 03/03/2020 | |
echo 'project-name,roles/rolename,user:username-and-serviceaccounts' > iamlist.csv | |
prjs=( $(gcloud projects list | tail -n +2 | awk {'print $1'}) ) | |
for i in "${prjs[@]}" | |
do | |
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" | |
echo "Collecting IAM roles & users for Project: $i" | |
echo $(gcloud projects get-iam-policy $i --format="table(bindings)[0]" | sed -e 's/^\w*\ *//'|tail -c +2 |python reformat.py $i >> iamlist.csv) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment