Skip to content

Instantly share code, notes, and snippets.

@jillesvangurp
Created October 20, 2016 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jillesvangurp/fb8ee1fce482846ab12cb0c37a3a1b4f to your computer and use it in GitHub Desktop.
Save jillesvangurp/fb8ee1fce482846ab12cb0c37a3a1b4f to your computer and use it in GitHub Desktop.
jq expression to get a csv out of aws describe-instances
# we have Name tags and environment_name tags so it makes sense to add those as columns
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" | jq --raw-output '.Reservations[].Instances[] | [.Placement.AvailabilityZone, .PrivateDnsName, .InstanceType, (.Tags[] | select(.Key == "Name").Value),(.Tags[] | select(.Key == "environment_name").Value)] | @csv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment