Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save randsina/a4eacf6ac320d212fac7a69fedde4316 to your computer and use it in GitHub Desktop.
Save randsina/a4eacf6ac320d212fac7a69fedde4316 to your computer and use it in GitHub Desktop.
How to sort AWS CLI describe-images output using jd

As an example query AWS for a list of all NAT Instance AMIs:


aws ec2 describe-images --filter Name="owner-alias",Values="amazon" --filter Name="name",Values="amzn-ami-vpc-nat*" --region us-west-2 | jq '.Images | sort_by(.CreationDate)'

If only specific fields are required to print into output:


aws ec2 describe-images --filter Name="owner-alias",Values="amazon" --filter Name="name",Values="amzn-ami-vpc-nat*" --region us-west-2 | jq '.Images | sort_by(.CreationDate) | .[] | {Name: .Name, Created: .CreationDate, Id: .ImageId}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment