Last active
October 27, 2016 16:00
-
-
Save ukn/0b0687c34f03254b7de331551a8c86ab to your computer and use it in GitHub Desktop.
bash function that formats `aws ec2 describe-instances` into something readable
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
awsls(){ | |
if [ -z ${1+x} ]; then | |
temp=`aws ec2 describe-instances` | |
else | |
temp=`aws ec2 describe-instances --profile ${1}` | |
fi | |
# All tags version | |
# aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + .PublicIpAddress + "\t" + .InstanceType + "\t" + (reduce.Tags[] as $tag (""; . + $tag.Key + "=" + $tag.Value + " "))' | |
echo $temp | jq -r '.Reservations[].Instances[] | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + ( if .PublicIpAddress then .PublicIpAddress else "\t" end) + "\t" + .InstanceType + "\t" + .State.Name + "\t " + (.Tags[] | select(.Key == "Name") | .Key + ":" + .Value)' | |
unset temp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment