getamis: search for AMI information¶
Overview:¶
I’ve not had a lot of luck finding a site on the net that’ll help search for amis for amazon. There’re more than a few and, at least the ones I’ve seen, all seem to fall short. Feel free to send me links if you have ideas that differ; but, they all seem to lack for me.
This function, mentioned in the sample env is pretty good for finding the latest ami for amazon linux 2; however, it’s hard coded. not a lot of flexibilty there:
idami()
{
aws ec2 describe-images --region ${region} \
--owners amazon \
--filters "Name=description,Values=Amazon Linux 2023*x86_64 HVM*" "Name=state,Values=available" \
--query 'Images | sort_by(@, &CreationDate) | [-1].{ID:ImageId}' \
--output text
}
aws ec2 describe-images
w/o filters or queries leads
to thousands of lines and, if you can get it in columnar
format, it’ll be from here to Canada.
Enter a python script to handle some of the parsing, searching for you.
Command:¶
getamis
is a python script that uses boto3. It’s got a reasonable
set of potential arguments most of which have defaults:
./getamis --help
usage: getamis [-h] [--region REGION] [--owner OWNER] [--owners] [--desc DESC] [--arch ARCH] [--search] [--latest]
AWS AMI search
options:
-h, --help show this help message and exit
--region REGION aws region - defaults to us-east-2
--owner OWNER ami owner - defaults to aws-marketplace
--owners list owners and ownerids in a region
--desc DESC ami description
--arch ARCH architecture - defaults to x86_64
--latest list latest AMI as part of search
If you just run it, you will get thousnads of lines about all the amis in the us-east-2 region:
./getamis | head -10
ami-071178a41f1661116 2023-04-13 CudaCGCCBYOL-v900-0511-aa5a6458-df82-4377-b7fc-61c72d308e48 CudaCGCCBYOL-v900-0511
ami-0830ebc84d45f31d7 2024-03-17 cognosys-109-2403170406-2c382860-4256-4dc3-a809-78ab951d5e75 Build Apps for Windows server 2012r2-24x7 Supported by Cogno
ami-0529b3e3b5ae34944 2023-06-01 bitnami-limesurvey-6.1.1-0-linux-debian-11-x86_64-hvm-ebs-na This image may not be the latest version available and might
ami-08d49200d69bb8612 2024-02-06 bitnami-mongodb-7.0.5-1-r03-linux-debian-11-x86_64-hvm-ebs-n MongoDB(R) packaged by Bitnami 7.0.5-1 (https://bitnami.com/
ami-003cfc206e44c5978 2023-12-11 websoft9-couchdb3.3.3-UbuntuLTS22.04-52e37001-6cdd-42cd-82dc
ami-0f646e3229db70091 2023-09-09 ProComputers RHEL-7.5-x86_64-Minimal-10GiB-HVM-20180322_1900 Red Hat Enterprise Linux 7 Minimal Install Golden AMI Templa
ami-07db3c968828c7f07 2024-01-27 bitnami-flink-1.18.1-0-linux-debian-11-x86_64-hvm-ebs-nami-3 Bitnami package for Apache Flink 1.18.1-0 (https://bitnami.c
ami-0442bbc56edc21191 2023-10-05 MQTTRoute_v2.0-a9ee82d6-abae-43e5-b4db-e670a930ad0b
ami-0cf1fbc649cb2c1d9 2023-01-12 Mysql8.0_CentOS Stream8_X86_GA-9971f961-84bd-47ba-8ed7-741d9
ami-0b79ef75109a280e5 2023-12-04 wazo-euc-stack-23.16-1701701069-prod-x3uyhb2qg6ppg Wazo E-UC Stack 23.16
That’s not all that useful unless you’re just skimming amis and the web sites will probably be better for that.
Owners:¶
List ownerids and aliases:
./getamis --owners
Unique AMI owner IDs and aliases in region 'us-east-2':
OwnerID Alias
============ ====================
172840064832 No Alias
634519214787 amazon
575461648593 No Alias
205223424851 amazon
602401143452 amazon
795746500882 No Alias
309956199498 amazon
[[snip]]
679593333241 aws-marketplace
[[snip]]
Searching by description:¶
Say you’re looking for the latest amazon linux 2 ami:
./getamis --desc 'amazon linux 2' --owner amazon
ami-059206ce34ec2d0d8 2023-09-26 amzn2-ami-kernel-5.10-hvm-2.0.20230926.0-x86_64-ebs Amazon Linux 2 Kernel 5.10 AMI 2.0.20230926.0 x86_64 HVM ebs
ami-02355eb7faca48e84 2024-02-28 Deep Learning Proprietary Nvidia Driver AMI (Amazon Linux 2) Supported EC2 instances: G3*, P3*, G5*, G4dn*, Inf1*. PyTorc
ami-0366c211ca7cdb765 2023-12-05 Deep Learning OSS Nvidia Driver AMI (Amazon Linux 2) Version Supported EC2 instances: P4*, P5*. PyTorch-2.0, TensorFlow-2
ami-0866a04d72a1f5479 2024-01-26 al2023-ami-2023.3.20240131.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240131.0 x86_64 HVM kernel-6.
ami-005b57ed2b65c8325 2023-07-12 Deep Learning Base Neuron AMI (Amazon Linux 2) 20230710 Supported EC2 instances: Inf1, Trn1, Trn1n, Inf2. Release no
ami-0cd4022121dd303b9 2022-12-14 Deep Learning AMI GPU CUDA 11.3.1 (Amazon Linux 2) 20221212 Built with NVIDIA CUDA, cuDNN, NCCL, GPU Driver, Docker, NVI
ami-0779bc7cb3b141dab 2022-12-14 amzn2-ami-amd-hvm-2.0.20221210.0-x86_64-gp2 Amazon Linux 2 AMD AMI 2.0.20221210.0 x86_64 HVM gp2
ami-0e53b23d4348ec17e 2022-07-13 Deep Learning AMI GPU TensorFlow 2.5.3 (Amazon Linux 2) 2022 Built with AWS optimized TensorFlow, NVIDIA CUDA, cuDNN, NCC
ami-0eba0deb2164027c2 2022-10-26 Deep Learning AMI GPU CUDA 11.4.3 (Amazon Linux 2) 20221024 Built with NVIDIA CUDA, cuDNN, NCCL, GPU Driver, Docker, NVI
ami-0cf549e4fe3c1249a 2023-05-10 Deep Learning AMI Neuron PyTorch 1.13 (Amazon Linux 2) 20230 Supported EC2 instances: Inf1, Trn1, Trn1n, Inf2. Release no
ami-07d984e14e48ea6fb 2023-11-17 amzn2-ami-hvm-2.0.20231116.0-x86_64-ebs Amazon Linux 2 AMI 2.0.20231116.0 x86_64 HVM ebs
ami-0e4bab9adfcf464b1 2023-11-17 amzn2-ami-hvm-2.0.20231116.0-x86_64-gp2 Amazon Linux 2 AMI 2.0.20231116.0 x86_64 HVM gp2
[[snip]]
That’s still several hundreds so we need to limit the search more. Looking through that list, using grep, or just plan searching, we find that amazon linux current versions have ‘al2023-ami-2023’ in the name or description, so search for that:
./getamis --owner amazon --desc 'al2023-ami-2023'
ami-02ca28e7c7b8f8be1 2024-02-16 al2023-ami-2023.3.20240219.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240219.0 x86_64 HVM kernel-6.
ami-019f9b3318b7155c5 2024-03-21 al2023-ami-2023.4.20240319.1-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.4.20240319.1 x86_64 HVM kernel-6.
ami-09694bfab577e90b0 2024-01-20 al2023-ami-2023.3.20240122.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240122.0 x86_64 HVM kernel-6.
ami-0e0bf53f6def86294 2024-03-13 al2023-ami-2023.3.20240312.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240312.0 x86_64 HVM kernel-6.
ami-0cd3c7f72edd5b06d 2024-01-05 al2023-ami-2023.3.20240108.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240108.0 x86_64 HVM kernel-6.
ami-022661f8a4a1b91cf 2024-03-01 al2023-ami-2023.3.20240304.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240304.0 x86_64 HVM kernel-6.
ami-0c20d88b0021158c6 2024-02-06 al2023-ami-2023.3.20240205.2-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240205.2 x86_64 HVM kernel-6.
ami-04f767d954fe2d2d1 2024-01-17 al2023-ami-2023.3.20240117.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240117.0 x86_64 HVM kernel-6.
ami-0866a04d72a1f5479 2024-01-26 al2023-ami-2023.3.20240131.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240131.0 x86_64 HVM kernel-6.
You can have the script filter the latest ami for you thusly:
./getamis --owner amazon --desc 'al2023-ami-2023' --latest
ami-0cd3c7f72edd5b06d 2024-01-05 al2023-ami-2023.3.20240108.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240108.0 x86_64 HVM kernel-6.
ami-019f9b3318b7155c5 2024-03-21 al2023-ami-2023.4.20240319.1-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.4.20240319.1 x86_64 HVM kernel-6.
ami-09694bfab577e90b0 2024-01-20 al2023-ami-2023.3.20240122.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240122.0 x86_64 HVM kernel-6.
ami-0866a04d72a1f5479 2024-01-26 al2023-ami-2023.3.20240131.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240131.0 x86_64 HVM kernel-6.
ami-022661f8a4a1b91cf 2024-03-01 al2023-ami-2023.3.20240304.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240304.0 x86_64 HVM kernel-6.
ami-0e0bf53f6def86294 2024-03-13 al2023-ami-2023.3.20240312.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240312.0 x86_64 HVM kernel-6.
ami-0c20d88b0021158c6 2024-02-06 al2023-ami-2023.3.20240205.2-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240205.2 x86_64 HVM kernel-6.
ami-02ca28e7c7b8f8be1 2024-02-16 al2023-ami-2023.3.20240219.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240219.0 x86_64 HVM kernel-6.
ami-04f767d954fe2d2d1 2024-01-17 al2023-ami-2023.3.20240117.0-kernel-6.1-x86_64 Amazon Linux 2023 AMI 2023.3.20240117.0 x86_64 HVM kernel-6.
Latest: ami-019f9b3318b7155c5
which matches what idami provides:
idami
ami-019f9b3318b7155c5
Summary:¶
The script will probably change over time as my research progresses; however, this is a good start.