Last Updated: December 28, 2016
· number5

Get the latest Ubuntu 12.04 official AMI using aws-cli with query option

aws --region ap-southeast-2 ec2 describe-images --owners 099720109477 \
    --filters Name=root-device-type,Values=ebs \
        Name=architecture,Values=x86_64 \
        Name=name,Values='*hvm-ssd/ubuntu-precise-12.04*' --query 'sort_by(Images, &Name)[-1].ImageId' --output text

1 Response
Add your response

Thanks. Here is my modification to find Ubuntu 16.04

for region in us-east-1 us-east-2 us-west-1 us-west-2 eu-west-1 eu-west-2 eu-central-1 ap-northeast-1 ap-southeast-1 ap-southeast-2 ca-central-1
ami=aws --region $region ec2 describe-images \ --filters Name=root-device-type,Values=ebs \ Name=architecture,Values=x86_64 \ Name=virtualization-type,Values=hvm \ Name=name,Values=*ubuntu-xenial-16.04-amd64-server-20161214 \ --query 'Images[*].{ID:ImageId}' --output text

echo $region, $ami


over 1 year ago ·