Last active
August 31, 2023 16:37
-
-
Save andytumelty/04f01b8a8106913c0827f1c8bb953815 to your computer and use it in GitHub Desktop.
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 get-instances() { | |
name=$1 | |
( | |
echo 'Name,PrivateIPAddress,State,LaunchTime (↓)' &&\ | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$name" |\ | |
jq -r '.Reservations[].Instances[] | | |
["\(.Tags | map(select(.Key == "Name").Value)[0])-\(.InstanceId)", .PrivateIpAddress, .State.Name, .LaunchTime] | | |
@csv' |\ | |
tr -d '"' |\ | |
sort -k 4 | |
) | column -t -s ',' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment