Skip to content

Instantly share code, notes, and snippets.

@DALDEI
Created February 16, 2017 04:58
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 DALDEI/36f29cf73a593c39725b1e70926f5dd2 to your computer and use it in GitHub Desktop.
Save DALDEI/36f29cf73a593c39725b1e70926f5dd2 to your computer and use it in GitHub Desktop.
Locate the latest published AWS EC2 AMI with AWS Linux, base AMI, HVM, EBS boot partition, latest kernal. 1-liner.
#!/bin/bash
aws ec2 describe-images --owners amazon --filters "Name=state,Values=available" \
"Name=architecture,Values=x86_64" \
"Name=root-device-type,Values=ebs" \
"Name=virtualization-type,Values=hvm" \
"Name=block-device-mapping.volume-type,Values=gp2" \
"Name=hypervisor,Values=xen" \
--query 'Images[?Description!=null]|[?contains(Description,`Amazon Linux`) == `true`]|\
[?contains(Description,` NAT `)==`false`]|[?contains(Description,` ECS `)==`false`]|\
sort_by(@, &CreationDate)[-1]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment