Last active
October 29, 2020 21:10
-
-
Save mijdavis2/52aadff85e52ec3b293bf639c3b218b7 to your computer and use it in GitHub Desktop.
Get "Name" tag for all AWS EC2 instances in a region
This file contains hidden or 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
#!/bin/bash | |
PROFILE=${AWS_PROFILE:-default} | |
TAG=${TAG:-Name} | |
STATE=${STATE:-running} | |
aws ec2 --profile ${PROFILE} describe-instances \ | |
--filters Name=instance-state-name,Values=${STATE} | \ | |
jq .Reservations[].Instances[].Tags | \ | |
jq -c ".[] | select(.Key | contains(\"${TAG}\"))" | \ | |
jq .Value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment