Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save florin-andrei-curbside/7a573ac0e417d304947ee2fce939c4a6 to your computer and use it in GitHub Desktop.
Save florin-andrei-curbside/7a573ac0e417d304947ee2fce939c4a6 to your computer and use it in GitHub Desktop.
get all public or private IPs from all EC2 instances in default region
#!/usr/bin/env bash
aws ec2 describe-instances --query 'Reservations[].Instances[].PublicIpAddress' --output=table | \
awk '{print $2}' | grep -v Describe | grep -v -e '^$'
aws ec2 describe-instances --query 'Reservations[].Instances[].PrivateIpAddress' --output=table | \
awk '{print $2}' | grep -v Describe | grep -v -e '^$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment