Latest Centos 7 AMI

2018-07-27 Nerd Software sergio

That’s around the internet but I keep searching for it every time, so here it is as a public memory:

Assuming:

  • You want an HVM, EBS backed, x86_64 image of the latest version of CentOS 7
  • You have configured the desired region and credentials for the AWS SDK
  • The Owner ID for the official CentOS organisation remains 679593333241
aws ec2 describe-images                                 \
  --owners 679593333241                                 \
  --filters                                             \
      Name=name,Values='CentOS Linux 7 x86_64 HVM EBS*' \
      Name=architecture,Values=x86_64                   \
      Name=root-device-type,Values=ebs                  \
  --query 'sort_by(Images, &Name)[-1].ImageId'     \
  --output text