AWS Builder Center
Understanding Amazon Machine Images (AMIs): How to Create and Deploy Custom Web Server Blueprints

Understanding Amazon Machine Images (AMIs): How to Create and Deploy Custom Web Server Blueprints

Learn how to create a custom "Golden AMI" on AWS EC2 and combine it with Launch Templates to rapidly deploy pre-configured, production-ready web servers in minutes.

When building scalable cloud applications on Amazon Web Services (AWS), manually installing software, setting up dependencies, and configuring web servers on every new virtual machine is inefficient and prone to human error.
An Amazon Machine Image (AMI) solves this problem by providing a pre-configured template containing the software stack, operating system, and disk contents needed to launch an EC2 instance.
In this guide, we will walk through what an AMI is, how to create one from a running web server, and how to combine it with an AWS Launch Template to automate server deployments.

What is an Amazon Machine Image (AMI)?

An Amazon Machine Image (AMI) is a master copy or "golden image" of an EC2 instance's root storage volume. It captures:
  • Operating System (e.g., Ubuntu, Amazon Linux)
  • Pre-installed Applications (e.g., Nginx, Apache, Node.js, Docker)
  • Custom Configurations & Code Files
Once created, an AMI allows you to launch dozens or hundreds of identical, fully configured instances in minutes without re-running setup scripts.

Step 1: Configure the Base EC2 Instance

Before creating an image, configure your base instance with the required software stack.
In this example, an Ubuntu instance (nginx-server1) was launched, and Nginx was installed and enabled using system service controls:

Step 2: Create a Custom AMI from the Running Instance

Once the base server is configured and tested, capture its state into an AMI:
  1. Open the AWS Management Console and navigate to EC2 > Instances.
  2. Select your running instance (nginx-server1).
  3. Click Actions -> Image and templates ->
  4. Create image.
  5. Provide an Image name (e.g., nginx-golden-ami) and description.
  6. Click Create image.
AWS will take a snapshot of the EBS root volume and register the AMI under EC2 > AMIs. Once processing completes, its status changes from Pending to Available.

Step 3: Create a Launch Template Using the Custom AMI

While you can launch instances directly from an AMI, combining an AMI with an AWS Launch Template captures both the software image AND the underlying hardware configuration (Instance Type, Security Groups, SSH Keys).

Setting Up the Launch Template:

  1. Navigate to EC2 > Launch Templates and click Create launch template.
  2. Name your template (e.g., nginx-webserver-template).
  3. Under Application and OS Images (Amazon Machine Image), choose My AMIs and select your newly generated nginx-golden-ami (ami-0de7500e71a72ef68).
  4. Select your desired Instance type (e.g., t3.micro), Key pair, and Security Group (allowing Port 80 for HTTP traffic).
  5. Click Create launch template.

Step 4: Deploy Pre-Configured Instances from the Template

To launch a new instance using the blueprint:
  1. Go to EC2 > Launch Templates.
  2. Select nginx-webserver-template, click Actions, and select Launch instance from template.
  3. Specify the Number of instances (e.g., 1) and click Launch instance.

Step 5: Verification

Once the new instance boots, connect via SSH or navigate to its public IP address:
The new server (ip-172-31-32-134) immediately runs Nginx out of the box without requiring manual package installation or setup scripts.

Difference Between AMI and Launch Template

FeatureAmazon Machine Image (AMI)Launch Template
What it savesDisk contents (OS, installed software, app code)Hardware & provisioning settings (Instance type, SG, Key Pair)
Primary purposeSoftware image backup / cloningInfrastructure standardization & Auto Scaling support

Key Takeaways

  1. AMIs save time: Creating a "Golden AMI" eliminates bootstrap delays and package repository timeouts during instance startup.
  2. Launch Templates standardize infrastructure: Saving hardware specs alongside your AMI enables seamless integration with EC2 Auto Scaling Groups and CI/CD deployment pipelines.
  3. Scale effortlessly: With an AMI and Launch Template in place, scaling from 1 to 100 identical web servers takes only a few clicks.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article