Created
May 28, 2023 23:05
-
-
Save ollytheninja/c5533d74f59991dfd23756bd0d08a080 to your computer and use it in GitHub Desktop.
Find the Auditor role and account name for an account ID, assume it and print EC2 instances
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
aws ec2 describe-instances | jq '.Reservations[].Instances[] | {InstanceId,KeyName,Tags,SecurityGroups}' | |
foreach ACCOUNT (1234567890 0987654321) | |
ROLE=$(cat ~/.aws/config | grep -B 3 $ACCOUNT | grep Auditor | sed -e 's/.* \(.*\)./\1/g') | |
echo $ROLE | |
assume $ROLE | |
aws ec2 describe-instances | jq '.Reservations[].Instances[] | {InstanceId,KeyName,Tags,SecurityGroups}' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment