[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#971545: cloud.debian.org: Provide AMI image ID that is always recent



On 2/10/20 3:55 am, Ross Vandegrift wrote:
> On Thu, Oct 01, 2020 at 05:16:36PM +0200, tkoeck wrote:
>> is there an AMI image ID that is always the recent one?
> 
> 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}'


There's a small tool I wrote earlier in the year to address the problem
of quickly finding the latest AMI for a given type. It is now hosted here:

https://github.com/sitepoint/amifinder

eg. running something like:

amifinder --name 'debian-10-amd64-*' 136693071363

in the us-west-2 region would give you:

Name: debian-10-amd64-20200928-407
Architecture: x86_64
CreationDate: 2020-09-28T23:58:51.000Z
ImageId: ami-06d8a32aedc6986f5
ImageLocation: 136693071363/debian-10-amd64-20200928-407
ImageType: machine
Public: True
OwnerId: 136693071363
State: available
  DeviceName: /dev/xvda
    DeleteOnTermination: True
    SnapshotId: snap-01eca3d280b2d9f69
    VolumeSize: 8
    VolumeType: gp2
    Encrypted: False
Description: Debian 10 (20200928-407)
EnaSupport: True
Hypervisor: xen
RootDeviceName: /dev/xvda
RootDeviceType: ebs
SriovNetSupport: simple
VirtualizationType: hvm

I feel it makes things a fair bit easier.

Cheers,
Adam

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: