Skip to Content

AMIs

Amazon Machine Images, where they come from, creating custom ones, copying and sharing them, and golden AMIs for fast launches.

What it is

An Amazon Machine Image (AMI) is the template an instance is launched from. It contains the operating system, any software and configuration added to it, and a list of the disks (EBS snapshots) to create.

A custom AMI is a customisation of an instance: the software, settings and monitoring agents are added once, save the result as an AMI, and every instance launched from it starts with all of that already in place. Boot and setup are much faster than installing everything at launch.

Instances can be launched from:

  • Public AMIs provided by AWS, such as Amazon Linux 2023, or by OS vendors. Ones from Amazon or verified partners are marked Verified provider.
  • Custom AMIs, which the account makes and maintains.
  • AWS Marketplace AMIs, made (and often sold) by other companies, for example a pre-configured firewall or a licensed database.

An AMI is specific to a Region (and to an OS, processor architecture and root volume type). To use it in another Region, it must be copied there.

Creating and using an AMI

In us-east-1 an instance is set up, a custom AMI is created with EBS snapshots, and new instances launch from it; the AMI is copied to eu-west-1 with a new AMI ID to launch instances there In us-east-1 an instance is set up, a custom AMI is created with EBS snapshots, and new instances launch from it; the AMI is copied to eu-west-1 with a new AMI ID to launch instances there

Create once, launch many times, copy to other Regions.
  1. Launch an instance and set it up: install software, apply updates, configure it.
  2. Stop it for data integrity. (If it isn't stopped, EC2 by default shuts it down and reboots it while creating the image, for the same reason. No reboot is an option when the disk is known to be consistent.)
  3. Create the AMI. EC2 takes EBS snapshots of the instance's volumes; the AMI points to them.
  4. Launch new instances from the AMI, in any AZ of the Region.
  5. Copy the AMI to another Region if needed. The copy gets a new AMI ID, and it can be encrypted during the copy.

The snapshot storage behind an AMI is billed until the AMI is deregistered and its snapshots are deleted.

Sharing AMIs

  • With specific AWS accounts, or with an organization or OU in AWS Organizations.
  • Publicly, with everyone (an account setting, block public access for AMIs, prevents this by default for new accounts).
  • Encrypted AMIs can be shared too, if the other account is also allowed to use the KMS key.
  • Sharing doesn't hand over ownership. The other account can copy the AMI to own its copy.

Golden AMIs and fast launches

A golden AMI is a company's approved, pre-built image with the OS, patches, security agents and the application already installed. Combined with other tricks, it gets a full stack running quickly:

  • EC2 instances:
    • a golden AMI for everything that's slow to install;
    • user data for the settings that change per launch (environment name, config URL);
    • a hybrid of both, which is what Elastic Beanstalk does.
  • RDS databases: restore from a snapshot, so the schema and data are already there.
  • EBS volumes: restore from a snapshot, so the disk is already formatted and filled.

EC2 Image Builder automates golden AMIs: it builds the image from a recipe on a schedule, tests it, and distributes it to other Regions and accounts.

Exam tips

  • "Launch instances faster", "pre-installed software", "reduce boot time" → a golden AMI (plus user data for dynamic settings).
  • "Use the same AMI in another Region" → copy the AMI to that Region.
  • "Share an AMI with another account" → modify the AMI's permissions (and the KMS key policy if it's encrypted).
  • "Automate building and patching AMIs" → EC2 Image Builder.

Common traps

  • "Launch an instance in eu-west-1 from an AMI ID in us-east-1." AMIs are Regional; copy it first.
  • "Deregistering the AMI stops the bill." Its snapshots remain and keep costing until they're deleted.
  • "Configure everything in user data to save building AMIs." Fine for small scripts, but slow for big installs; golden AMIs launch faster.

Hands-on lab: build and use a custom AMI

Goal: turn the web server into an AMI, launch a copy from it with no user data, and copy the AMI to another Region.

Costs money

Two t3.micro instances for a short time (about $0.02 an hour each), plus snapshot storage of about $0.05 per GB-month in each Region until you delete it. Together, a few cents.

Create the AMI

Use saa-web from the EC2 basics lab (launch it again if needed). Stop it, then choose Actions → Image and templates → Create image: name saa-web-ami, tag Project=saa-lab. Create.

Wait for it

Open Images → AMIs. When the status is Available, open Elastic Block Store → Snapshots: a new snapshot was created for the AMI.

Launch from your AMI

Select saa-web-ami and choose Launch instance from AMI: name saa-from-ami, t3.micro, key pair saa-lab-key, security group saa-web-sg, no user data. Launch, then open its public IP in the browser. The web page works straight away: the web server was already in the image.

Copy to another Region

Select the AMI, Actions → Copy AMI, destination Region US West (Oregon). Switch the console to us-west-2: the copy appears under AMIs with a different AMI ID.

Expected result: an instance that serves the web page without any setup, and the same image available in a second Region.

Clean up: terminate saa-from-ami and saa-web. In each Region, deregister the AMI, then delete its snapshot under Snapshots.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt