AWS AMI- Amazon Machine Image

Gaurav Gupta
5 min readOct 14, 2019

--

Amazon Machine Image provides the information required to launch an instance.

An AMI includes the following:

  • One or more EBS snapshots, or, for instance-store-backed AMIs, a template for the root volume of the instance (for example, an operating system, an application server, and applications).
  • Launch permissions that control which AWS accounts can use the AMI to launch instances.
  • A block device mapping that specifies the volumes to attach to the instance when it’s launched

Using an AMI:

After you create and register an AMI, you can use it to launch new instances.

“ Amazon Linux 2 and Amazon Linux AMI: Amazon Linux AMI is not based upon any Linux distribution. Rather, the Amazon Linux AMI is independently maintained image by Amazon”

AMI Types:

You can select an AMI to use based on the following characteristics:

  • Region (see Regions and Availability Zones)
  • Operating system
  • Architecture (32-bit or 64-bit)
  • Launch Permissions
  • Storage for the Root Device

Let’s discuss few characteristics in details:

Launch Permissions

The owner of an AMI determines its availability by specifying launch permissions. Launch permissions fall into the following categories.

Storage for the Root Device:

All AMIs are categorized as either backed by Amazon EBS or backed by instance store.

Amazon EBS-backed based AMI can be terminated & stop-start(restart)

Amazon Instance Store-backed AMI can’t be restarted only terminate or running.

Linux AMI — Virtualization Types

Linux Amazon Machine Images use one of two types of virtualization: Paravirtual (PV) or Hardware virtual machine (HVM). The main differences between PV and HVM AMIs are the way in which they boot and whether they can take advantage of special hardware extensions (CPU, network, and storage) for better performance.

For the best performance, we recommend that you use current generation instance types and HVM AMIs when you launch your instances.

HVM AMIs

HVM AMIs are presented with a fully virtualized set of hardware and boot by executing the master boot record of the root block device of your image. This virtualization type provides the ability to run an operating system directly on top of a virtual machine without any modification Unlike PV guests, HVM guests can take advantage of hardware extensions that provide fast access to the underlying hardware on the host system. All instance types support HVM AMIs.

PV (Paravirtual) AMIs

PV AMIs boot with a special boot loader called PV-GRUB, which starts the boot cycle and then chain loads the kernel specified in the menu.lst file on your image. The following previous generation instance types support PV AMIs: C1, C3, HS1, M1, M3, M2, and T1. Current generation instance types do not support PV AMIs.

Finding a Linux AMI through AWS CLI:

Check my previous post for this: Find a Linux AMI- AWS

Few Important Concepts related to AMI:

Google for below important concepts of AMI.

  • Shared AMIs
  • Finding Shared AMIs
  • Making an AMI public — Select your AMI, choose Actions, Modify Image Permissions.
  • Sharing an AMI with Specific AWS Accounts: You can share an AMI with specific AWS accounts without making the AMI public. All you need is the AWS account IDs.
  • Guidelines for Shared Linux AMIs: Use the following guidelines to reduce the attack surface and improve the reliability of the AMIs you create.

Creating a Linux AMI from an Instance:

AMI Tools:

You can use the AMI tools commands to create and manage instance store-backed Linux AMIs.

Deregistering Your Linux AMI:

You can deregister an AMI when you have finished using it. After you deregister an AMI, you can’t use it to launch new instances.

When you deregister an AMI, it doesn’t affect any instances that you’ve already launched from the AMI.

Cleaning Up your Amazon EBS-Backend AMI:

Cleaning Up your Amazon Instance Store-Backed AMI:

What is Cloud-Init:

Cloud-Init:

The cloud-init package is an open-source application built by Canonical that is used to bootstrap (it initializes the operating system during startup) Linux images in a cloud computing environment, such as Amazon EC2. Amazon Linux contains a customized version of cloud-init. It enables you to specify actions that should happen to your instance at boot time.

Running Amazon Linux 2 as a Virtual Machine On-Premises:

Use the Amazon Linux 2 virtual machine (VM) images for on-premises development and testing. These images are available for use on the following virtualization platforms:

VMWare

KVM

VirtualBox (Oracle VM)

Microsoft Hyper-V

--

--