Skip to content

Instantly share code, notes, and snippets.

@nikolay
Last active March 27, 2017 22:19
Show Gist options
  • Save nikolay/12f4ca2a592bbfa0df57c3bbccb92f0f to your computer and use it in GitHub Desktop.
Save nikolay/12f4ca2a592bbfa0df57c3bbccb92f0f to your computer and use it in GitHub Desktop.
Get the latest Amazon Linux AMI ID
aws ec2 describe-images \
--owners amazon \
--filters \
'Name=name,Values=amzn-ami-hvm-????.??.?.????????-x86_64-gp2' \
'Name=state,Values=available' \
'Name=architecture,Values=x86_64' \
'Name=virtualization-type,Values=hvm' \
'Name=root-device-type,Values=ebs' \
--query 'sort_by(Images, &CreationDate)[-1].ImageId'
aws ec2 describe-images \
--owners amazon \
--filters \
'Name=name,Values=amzn-ami-????.??.g-amazon-ecs-optimized' \
'Name=state,Values=available' \
'Name=architecture,Values=x86_64' \
'Name=virtualization-type,Values=hvm' \
'Name=root-device-type,Values=ebs' \
--query 'sort_by(Images, &CreationDate)[-1].ImageId'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment