Skip to content

Instantly share code, notes, and snippets.

@k5njm
Created February 2, 2018 14:36
Show Gist options
  • Save k5njm/56ac4fd0a294df8ff49b82771d08cf63 to your computer and use it in GitHub Desktop.
Save k5njm/56ac4fd0a294df8ff49b82771d08cf63 to your computer and use it in GitHub Desktop.
if [ -z "$1" ]
then
region_list=($(aws ec2 describe-regions --query 'Regions[].RegionName[]' --output text | gsed -e 'y/\t/\n/' | gsed '1!G;h;$!d'))
else
region_list=$1
fi
clear
for i in "${region_list[@]}"
do
echo "Checking $i..."
# aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,LaunchTime,InstanceType,Tags[?Key==`Name`].Value,State.Name]' --output text --region $i
# echo "---------"
# echo ""
aws ec2 describe-instances --query 'Reservations[].Instances[].[{Name:Tags[?Key==`Name`] | [0].Value, ID:InstanceId, AZ:Placement.AvailabilityZone, Status:State.Name, Type: InstanceType, PublicIP:NetworkInterfaces[].Association[] | [0].PublicIp}]' --output table --region $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment