Created
May 26, 2022 12:17
-
-
Save look4regev/5b10af280914035fa700b88a9dd9773d to your computer and use it in GitHub Desktop.
Get AWS EC2s IPs by name tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTANCE_NAME=$1 | |
ips=$(aws ec2 describe-instances --filters="Name=tag:Name,Values=${INSTANCE_NAME}" --query="Reservations[*].Instances[*].PrivateIpAddress" --output=text) | |
for i in $(cat ips | tr '\t\n' ',' | tr ',' '\n'); do echo $i; ssh $i -q -t "hostname"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment