Skip to content

Instantly share code, notes, and snippets.

@sandromello
Created April 6, 2016 12:43
Show Gist options
  • Save sandromello/9c6ef558b3da49557d515495df117b4f to your computer and use it in GitHub Desktop.
Save sandromello/9c6ef558b3da49557d515495df117b4f to your computer and use it in GitHub Desktop.
aws-cli get instances ips
#!/bin/bash
searchString=$1
IpSearchType=PublicIpAddress
if [ "$1" = "private" ]; then
IpSearchType=PrivateIpAddress
searchString=$2
else
IpSearchType=PublicIpAddress
fi
aws ec2 describe-instances --query "Reservations[].Instances[].[$IpSearchType, Tags[?Key==\`Name\`].Value[], Placement]" --filters Name=tag:Name,Values=$searchString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment