Last active
August 6, 2021 23:27
-
-
Save belminf/6d55c21e3d0499eaca09 to your computer and use it in GitHub Desktop.
AWS CLI command to find latest RHEL and Ubuntu images using JMESPath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Both are limited to HVM-based 64-bit AMIs backed by EBS | |
# Red Hat's latest GA images | |
alias ami_rhel="aws ec2 describe-images \ | |
--filters \ | |
'Name=root-device-type,Values=ebs' \ | |
'Name=architecture,Values=x86_64' \ | |
'Name=virtualization-type,Values=hvm' \ | |
'Name=name,Values=*GA*' \ | |
--owners 309956199498 \ | |
--output table \ | |
--query 'reverse(Images.sort_by([], &CreationDate))[].[ImageId, Name]'" | |
# Canonical's 20 latest non-beta/testing images | |
alias ami_ubuntu="aws ec2 describe-images \ | |
--filters \ | |
'Name=root-device-type,Values=ebs' \ | |
'Name=architecture,Values=x86_64' \ | |
'Name=virtualization-type,Values=hvm' \ | |
--owners 099720109477 \ | |
--output table \ | |
--query 'reverse(Images.sort_by([], &CreationDate))[?contains(Name,\`test\`)==\`false\`]|[?contains(Name,\`beta\`)==\`false\`]|[?contains(Name,\`Snappy\`)==\`false\`]|[0:20].[ImageId, Name]'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment