Skip to content

Instantly share code, notes, and snippets.

@rch317
Created December 31, 2016 15:16
Show Gist options
  • Save rch317/36962bcae0ad29e826ccf17a47acd94a to your computer and use it in GitHub Desktop.
Save rch317/36962bcae0ad29e826ccf17a47acd94a to your computer and use it in GitHub Desktop.
List out public IP usage per region
#!/bin/sh
for region in $(aws ec2 describe-regions |jq -r '.Regions[] | .RegionName');
do
echo "${region}"; aws ec2 describe-instances --region ${region} | \
jq -r '.Reservations[]
| .Instances[]
| select(.PublicIpAddress!=null)
| "\t" + .PublicIpAddress + " " + .InstanceId'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment