Created
November 24, 2020 14:57
-
-
Save tschant/f68b1162fca1797eb7beb6f02a9ad1e3 to your computer and use it in GitHub Desktop.
Search running AWS EC2 instances for tag value, return IP and 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
function aws-search-ec2() { | |
if [ "$1" ] | |
then | |
echo "Searching running EC2 for: $1" | |
aws ec2 describe-instances \ | |
--query "Reservations[*].Instances[*].[PrivateIpAddress, Tags[*].Value]" \ | |
--output text \ | |
--filters Name=instance-state-name,Values=running Name=tag-key,Values=Name Name=tag-value,Values="$1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment