If you’re a developer or sysadmin who needs to create Amazon Machine Images (AMIs) for use with Amazon Web Services (AWS), this guide is for you. In this article, we’ll show you how to create custom AMIs using the AWS Management Console and the AWS Command Line Interface (CLI). We’ll also show you how to use the AWS CloudFormation tool to create and manage your AMIs. Creating custom AMIs can be helpful if you need a specific configuration or want to use a specific version of an AWS service. For example, you might want to create an AMI that uses the latest version of Amazon Elastic Compute Cloud (EC2) or Amazon Simple Storage Service (S3). You can also use custom AMIs to test new versions of your applications before deploying them on production servers. To create a custom AMI, first open the AWS Management Console and navigate to the EC2 section. In the EC2 section, click on Images in the left column and then click on Create Image in the right column. The Create Image dialog box will appear. In this dialog box, type a name for your image and select an instance type from the list on the left side of the dialog box. On the right side of this dialog box, select an image size from one of three sizes: Small (1GB), Medium (4GB), or Large (10GB). Click on Next button and then specify a location where you want to store your image file. Click on Next button again and then specify whether you want your image to be encrypted with AES-256 encryption. Finally, click on Finish button to create your image. Now that we have created our first custom AMI, let’s see how we can use it in practice by creating an instance using this image. To do so, open the AWS CLI and type aws ec2 run-instances –image my-image-name –count 1 ..


AMIs are similar to operating system ISOs but are more than a simple OS. They are base templates that you can build on top of; they contain the OS, preinstalled software, and configuration files that the server needs to function.

AMIs Are More Than an Operating System

However, there are many AMIs that contain extra software suited for different tasks. AWS has a whole community browser for these, where a quick scroll will find you many AMIs like this:

This AMI is based on Ubuntu and comes with drivers and software intended to be used with Nvidia GPUs for machine learning. There are premade images for all sorts of things on the community browser.

All of the AMIs on the community browser were created by someone, and you can do the same. Say you’re hosting a web app, and you want to spin up a second server, either for redundancy or just to meet increasing demands. You could choose a blank AMI, spend an afternoon installing everything you need to run your app, copy your code over, and troubleshoot the eventual errors.

Or, you could make an AMI based off of your current server, and spin up a perfect clone in a few minutes. This saves you the headache of reinstalling and reconfiguring nginx every time you make a new instance.

Create Your Own Images to Package Your Platform

One small note: If you’re planning on using multiple servers for a single service, you’ll likely want to have an Elastic Load Balancer sitting in front of them. This will allow you to point your DNS to the load balancer and have traffic balanced between all of your instances. Without it, there’s not much point to having multiple servers.

Creating an AMI is simple—you can easily copy your current server, or you can create a new server to set up the AMI with exactly what you want. Whichever route you choose, when you’re done configuring the server, head over to the EC2 Management Console and find your instance in the Instances list.

Right-click your instance and select Image > Create Image. You’ll be brought to this dialog, where there isn’t much to do except give your instance a name and optional description.

By default, AWS will create a snapshot of your root EBS volume to base your AMI off of. This snapshot includes your OS, all of your installed software, and your files.

You’ll likely want to have some way of keeping your code up to date past the AMI creation, whether that’s regularly creating new AMIs for major changes, employing version management with git, running containerized applications with Docker, or simply using EFS to provide all of your instances with a shared file system.

Your AMI will take a few minutes to create, depending on the size of your root EBS volume. Once it’s done, it will be viewable in the “AMIs” tab of the EC2 Management Console.

When you create a new server, you can choose your AMI under the “My AMIs” tab:

You can also right-click the AMI in the AMIs tab to launch an instance using that AMI.

Using Custom AMIs as a Base for Autoscaling Groups

Autoscaling groups are a fantastic feature of AWS—they can allow your network to scale up to meet demand, and scale down when demand is low. If an instance in the autoscaling group becomes unhealthy (i.e., overloaded with traffic), a new instance can be created automatically to help meet the traffic needs. Often, you’re able to use EC2 Spot instances, which can be much cheaper than renting On-Demand.

Once you’ve set your AMI, you can create the rest of the autoscaling group as usual.

This helps a lot with load times of new servers; if you’re constantly spinning up new servers to efficiently meet fluctuations in demand, your biggest bottleneck will be how long it takes to get your server booted, running, and handling client requests.

Rather than waiting minutes for software to install, having everything preinstalled on an AMI reduces boot times to little more than the 45 seconds or so it takes to launch a regular EC2 instance.