Last active
January 28, 2016 06:48
-
-
Save tmtk75/cdcd7ae27ab13fc2eab7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
sort_key=${1-Name} | |
aws ec2 describe-instances \ | |
--output table \ | |
--filter Name=instance-state-name,Values=running \ | |
Name=tag-key,Values=role \ | |
Name=tag-key,Values=site \ | |
--query ' | |
sort_by( | |
Reservations[].Instances[], | |
&(Tags[?Key==`'$sort_key'`]|[0].Value) | |
)[] | |
.[ | |
Tags[?Key==`Name`]|[0].Value, | |
Tags[?Key==`site`]|[0].Value, | |
Tags[?Key==`role`]|[0].Value, | |
InstanceType, | |
InstanceId, | |
PublicIpAddress, | |
PrivateIpAddress, | |
Placement.AvailabilityZone | |
]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment