Ninja magic with AWS command line tools

AWS has one of the best CLIs of any cloud platform. The recent Python-based awscli release is just a pleasure to use because it outputs in JSON by default. This means you can use a tool like jq to put together a power tool-chain that acts on JSON data.

For example, this is how I find NAT AMIs that do not have "beta" in their name:

aws ec2 describe-images --region=us-west-2 | jq '.Images | map(select(.Name and (.Name | contains("ami-vpc-nat")) and (.Name | contains("beta") | not)))'