Skip to content

Instantly share code, notes, and snippets.

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