This is the fourth and final part of the EC2 storage series. We will discuss how you can create an Amazon EBS-Backed Linux AMI.

These will be the topics discussed in this part:

  • * Introductory information about AMIs
  • * Create an Amazon EBS-Backed Linux AMI
  • * Launch an instance from the AMI

An Amazon Machine Image (AMI) has all the information needed to launch an EC2 instance. When you launch an instance, you can specify an AMI of yours and you can launch as many instances you want from your AMI.

The purpose of creating your own AMIs is that you can have a very specific type of instance that you can launch every time and as many times you want. Let’s say that you have a customized PHP/MySQL/Apache server that runs on Linux. And you need to deploy a lot of them. Instead of applying the same configuration on each server one at a time and installing the software that you need, you could build an AMI based on one already running instance. From there, every time you need to deploy a server, you could do it based on the AMI created. Once that instance comes up, it will have everything you need without spending time with your standard configuration.

As a side note, you can create Linux AMI either EBS-backed or Instance Store-backed. Also, you can do the same for Windows AMI.

There are many differences between creation of instance store-backed AMIs and EBS-backed AMIs. Also, there are differences between Linux and Windows AMIs.

The article will cover only the creation of Amazon EBS-Backed Linux AMI.

Remember that when an EBS backed AMI is created, it is automatically registered by AWS. Once you don’t need the AMI anymore, you can deregister it and you will no longer be able to launch new instances from that AMI. However, whatever instances are already launched from that AMI, they will continue to run.

First you need to launch an image from an AMI that is similar to what you would like to create. There is no sense to launch a Windows instance if you want to have a Linux EBS-Backed AMI.

Once that instance is configured according to your needs, you can go ahead and create your AMI. When an AMI is created, actually a snapshot of the instance volumes is taken. Because the snapshot is a mirror of the volume at the exact time, it’s possible that not all the data would be captured (you might have data in buffers that is not yet written on the disks). Therefore, the recommendation is to stop the instance, to make sure that all the data will be captured.

After the AMI creation process is finished, you have a new AMI and a snapshot from the instance root device. If you launch a new instance using the new AMI, then the root device for the new instance will be based on the snapshot previously created.

So, how to create a new AMI?

From the EC2 Dashboard, go to ‘Instances’ from ‘INSTANCES’ menu. Select the image based on which you want to create the AMI and from ‘Actions’ select ‘Create Image’:

In the next window, fill out the AMI name and description and add another EBS volume and then click on ‘Create Image’:

Once this is done, go to ‘AMIs’ from ‘IMAGES’ menu and you should see your new AMI. It might take awhile until the status of the AMI will change to available:

Note that we have two volumes: one with 8GB and the other with 100GB.

And that’s it. We are done. Now, it’s time to launch an instance from this new AMI.

From ‘AMIs’ menu, click on ‘Launch’ and follow the normal process of launching a new instance:

This is the result of launching a new instance:

You can launch as many instances as you want from this AMI now.

In case you don’t need any more, you should deregister it. From the ‘AMIs’ menu, select the AMI that you want to deregister, go to ‘Actions’ and then select ‘Deregister’:

But this is not all. You deregistered the AMI, but you didn’t clean up everything. As you might remember, a snapshot is created during AMI creating process. That is not deleted when you deregister an AMI. You will have to delete it manually. You can see the snapshot:

You can allow others to use this AMI and launch new instances. For this you have to make the AMI public. You have the option to allow specific AWS account to access this AMI. In our case I made the AMI available for the whole wide world. Select the AMI and then select the ‘Permissions’ tab. Click on ‘Edit’ and then choose ‘Public’ and save the changes:

After this, others can use your AMI. To use other AMIs, from the EC2 console, select ‘AMIs’ and from the first filter, select ‘Public Images’:

Then on search field, type the name of the AMI name that you are looking for. In my case it was MY_AMI_LINUX_HTTP_SERVER:

As you can see, our AMI is found and that is good news. There might be two AMIs with the same name, but each user has a unique Owner ID (which I blurred in the above screenshot), so a combination between AMI name and Owner will take to the AMI that you are looking for.

And we reached the end of the article and of the series.

In this article, we learned about AMIs, how you can create them and how you can launch instances based on the AMIs that we created.

During the series, we got familiarized with EC2 storage options and how we can use them.

The level of knowledge reached with this series is enough for you to have a fast start in using AWS EC2, especially the storage features and by using the reference links provided at the end of each part of the series, you will get deeper knowledge with regards to EC2 storage.