Find a Linux AMI- AWS

Gaurav Gupta
2 min readSep 23, 2019

Before you can launch an instance, you must select an AMI to use. As you select an AMI, consider the following requirements you might have for the instances that you’ll launch:

-> The Region

-> The operating system

-> The architecture: 32-bit (i386), 64-bit (x86_64), or 64-bit ARM (arm64)

-> The root device type: Amazon EBS or instance store

-> The provider (for example, Amazon Web Services)

You can find Linux AMIs using the Amazon EC2 console. Just launch any type of EC2 instance, once it’s available, SSH on that server.

Before we find the AMI, make sure below things should be installed & configured on your server/instance.

  • “aws configure” should be done on your instance with one region so that it takes region.
  • “jq” (jq is like sed for JSON data)package should be installed on your instance. yum install jq -y or apt-get install jq -y

The describe-images command supports filtering parameters. For example, use the — owners parameter to display public AMIs owned by Amazon.

aws ec2 describe-images --owners self amazon

You can add the following filter to the previous command to display only AMIs backed by Amazon EBS:

- -filters “Name=root-device-type,Values=ebs”

Find the current Amazon Linux 2 AMI:

aws ec2 describe-images — owners amazon — filters ‘Name=name,Values=amzn2-ami-hvm-2.0.????????-x86_64-gp2’ ‘Name=state,Values=available’ — output json | jq -r ‘.Images | sort_by(.CreationDate) | last(.[]).ImageId’

Find the current Amazon Linux AMI:

aws ec2 describe-images — owners amazon — filters ‘Name=name,Values=amzn-ami-hvm-????.??.?.????????-x86_64-gp2’ ‘Name=state,Values=available’ — output json | jq -r ‘.Images | sort_by(.CreationDate) | last(.[]).ImageId’

Find the current Ubuntu Server 16.04 LTS AMI:

aws ec2 describe-images — owners 099720109477 — filters ‘Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-????????’ ‘Name=state,Values=available’ — output json | jq -r ‘.Images | sort_by(.CreationDate) | last(.[]).ImageId’

Find the current Red Hat Enterprise Linux 7.5 AMI:

aws ec2 describe-images — owners 309956199498 — filters ‘Name=name,Values=RHEL-7.5_HVM_GA*’ ‘Name=state,Values=available’ — output json | jq -r ‘.Images | sort_by(.CreationDate) | last(.[]).ImageId’

Find the current SUSE Linux Enterprise Server 15 AMI:

aws ec2 describe-images — owners amazon — filters ‘Name=name,Values=suse-sles-15-v????????-hvm-ssd-x86_64’ ‘Name=state,Values=available’ — output json | jq -r ‘.Images | sort_by(.CreationDate) | last(.[]).ImageId’

--

--