On Thu, Oct 01, 2020 at 05:16:36PM +0200, tkoeck wrote:
> is there an AMI image ID that is always the recent one?

That's not how AWS works - every image is always a different ID, just
like every instance is always a different ID.

Instead of hardcoding an AMI somewhere, you can search to find the
current release.  With awscli, try something like this:
$ aws ec2 describe-images \
        --output text \
        --owners 136693071363 \
        --filters Name=name,Values="debian-10-amd64-*" \
        --query 'Images[].[Name,ImageId]' \
        | sort -rn \
        | head -n 1 \
        | awk '{print $2}'


If you're using terraform, the aws_ami data source works like this:
data "aws_ami" "debian10" {
  most_recent = true
  owners      = ["136693071363"]

  filter {
    name = "name"
    values = ["debian-10-amd64-*"]
  }
}

Ross

Reply via email to