Skip to content

Instantly share code, notes, and snippets.

@sharuzzaman
Created May 6, 2020 20:47
Show Gist options
  • Select an option

  • Save sharuzzaman/7df2e14d4d0dd313deb791040c59496f to your computer and use it in GitHub Desktop.

Select an option

Save sharuzzaman/7df2e14d4d0dd313deb791040c59496f to your computer and use it in GitHub Desktop.
Get a list of EC2 instances that is currently running, and sort its output by name
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" | jq '.Reservations[]|.Instances[]|{InstanceId,PrivateIpAddress,Name: .Tags[]|select(.Key == "Name").Value}' | jq -n '[inputs]|sort_by(.Name)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment