Last active
September 22, 2020 19:11
-
-
Save davxiao/66a0c9f8f5bbe4ad543056e2b056ecd2 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# https://gist.github.com/davxiao/66a0c9f8f5bbe4ad543056e2b056ecd2 | |
# | |
function usage | |
{ | |
echo "This script generates AWS CLI commands for enumerating VPCs in specified accounts and regions." | |
echo "Edit script to add profile names and regions." | |
} | |
# awsprofile=('default') | |
# awsregion=('us-east-1' 'ca-central-1') | |
awsprofile=() | |
awsregion=() | |
if [ "$awsprofile" = "" ] | |
then | |
usage | |
exit | |
fi | |
for profile in "${awsprofile[@]}" | |
do | |
for region in "${awsregion[@]}" | |
do | |
echo "aws --profile ${profile} --region ${region} ec2 describe-vpcs --query 'Vpcs[*].{Account:\`${profile}\`,Region:\`${region}\`,VpcId:VpcId,VpcName:Tags[?Key==\`Name\`].Value |[0],Cidr:CidrBlock}' --output text ; " | |
done | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment