AWS Series — AMI: The blue print of your virtual machine

AWS Series — AMI: The blue print of your virtual machine

Consider a person working in IT has to configure 100s of virtual machines for the new joiners with the same basic settings. Should he select each option and install applications that they need on each virtual machine? This is a tedious task. What is the solution?

AMI : Amazon Machine Image —

An Amazon Machine Image (AMI) provides the information required to launch the instance. You must specify AMI when you launch the image.

AMI is just a blueprint of an EC2 instance

For any AMI, the key basic things that is configured —

  • AWS region
  • Operating System
  • Architecture (32-bit or 64-bit)
  • Launch Permissions
  • Storage for the root device ( root device volume)

All AMIs are backed by:

  • Amazon EBS — The root device for an instance launched from the AMI is an Amazon EBS volume created from an Amazon EBS snapshot
  • Instance Store — The root device for an instance launched from the AMI is an instance store volume created from a template stored in Amazon S3

What is Instance Store Volumes?

Instance Store Volumes are sometimes called ephemeral storage. Instance store volumes cannot be stopped. If the underlying host fails, you will lose your data. You can, however, reboot the instance without losing your data.

If you delete the instance, you will lose the instance store volume.

What is EBS Volumes?

EBS-backed instances can be stopped. You will not lose the data on this instance if it is stopped. You can also reboot an EBS volume and not lose your data.

By default, the root device volume will be deleted on termination. However, you can tell AWS to keep the root device volume with EBS volumes.

Create Instance1 with Delete on Termination as Yes —

Let us see in AWS Management Console > create EC2 instance > leave the default settings > select key pair and default security group. Create the instance. Once it is created, select the instance and go to storage section.

You can see the volume attached to it. If you scroll right, you can find Delete on Termination option which is marked as Yes. Which means, fi E2 instance is deleted the volume is also deleted.

Go to the instance> select it > Instance State > Terminate Instance

Go to Storage and find the volume ID. On the left panel > Volumes

You will no more find the volume.

Create Instance 2 with Delete on Termination as No —

Let us create a new EC2 instance and provide the default settings. Go to the Configure Storage

Click on Advanced and click on the volume.

Select the Delete on termination option as No. Now launch the instance.

If this instance is deleted, the root volume will not be deleted.

Now select the instance and Terminate the instance.

Find the volume under volumes and you will find the volume not deleted.

Create Instance 3 with Instance Store —

Create a new instance EC2. Go to AMI and Browse for more AMI

In the filter , select the Instance store type and you will get all the instances with the ephemeral storage. Select the top most which is Amazon AMI.

The instance type in this case would be changed to c3.large which will cost and not in free tier.

Now launch the instance.

Stop the instance. You will get the error that it cannot be stopped.

The data volume does not persist. We can terminate the instance and it deletes the volume as well.

Points to Remember —

  • Instance store volumes are sometimes called ephemeral storage.
  • Instance store volumes cannot be stopped. If the underlying host fails, you will lose your data.
  • EBS-backed instances can be stopped. You will not lose the data on this instance if it is stopped.
  • You can reboot both EBS and instance store volumes and you will not lose your data
  • By default, both root volumes will be deleted on termination. However, with EBS volumes, you can tell AWS to keep the root device volume.