Skip to content

Instantly share code, notes, and snippets.

@ayosec
Last active May 1, 2020 20:16
Show Gist options
  • Save ayosec/1991ab9a674c1ad86438fa359cf20d38 to your computer and use it in GitHub Desktop.
Save ayosec/1991ab9a674c1ad86438fa359cf20d38 to your computer and use it in GitHub Desktop.
#!/bin/bash
export AWS_DEFAULT_REGION=${REGION:-eu-west-1}
aws ec2 describe-addresses \
--query 'Addresses[*][InstanceId, PublicIp]' \
--output text \
| while read ID IP
do
echo -en "$IP\\t"
aws ec2 describe-instances \
--instance-ids $ID \
--query "Reservations[].Instances[].Tags[?Key=='Name'].Value" \
--output text
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment