Skip to content

Instantly share code, notes, and snippets.

@andytumelty
Last active August 31, 2023 16:37
Show Gist options
  • Save andytumelty/04f01b8a8106913c0827f1c8bb953815 to your computer and use it in GitHub Desktop.
Save andytumelty/04f01b8a8106913c0827f1c8bb953815 to your computer and use it in GitHub Desktop.
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