Skip to content

Instantly share code, notes, and snippets.

@dbt4u
Created September 24, 2019 16:56
Show Gist options
  • Save dbt4u/5284278f952ee67d28e05f6820731663 to your computer and use it in GitHub Desktop.
Save dbt4u/5284278f952ee67d28e05f6820731663 to your computer and use it in GitHub Desktop.
Counts all EC2 Instances grouped by Type and State
aws ec2 describe-instances | jq -r "[[.Reservations[].Instances[]|{ state: .State.Name, type: .InstanceType }]|group_by(.state)|.[]|{state: .[0].state, types: [.[].type]|[group_by(.)|.[]|{type: .[0], count: ([.[]]|length)}] }]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment