Skip to content

Instantly share code, notes, and snippets.

@davxiao
Last active September 22, 2020 19:11
Show Gist options
  • Save davxiao/66a0c9f8f5bbe4ad543056e2b056ecd2 to your computer and use it in GitHub Desktop.
Save davxiao/66a0c9f8f5bbe4ad543056e2b056ecd2 to your computer and use it in GitHub Desktop.
#!/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