Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cori/9c2ee4a02d4d2e47d3bd9e1a3e5f842e to your computer and use it in GitHub Desktop.
Save cori/9c2ee4a02d4d2e47d3bd9e1a3e5f842e 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