03 / 04

What is an Amazon Machine Image (AMI)?

An Amazon Machine Image (AMI) is a pre-configured template that contains the operating system, application server, and applications required to launch an EC2 instance, serving as the foundational building block for creating virtual servers in AWS.

An Amazon Machine Image (AMI) is a pre-configured template that provides the information required to launch an EC2 instance. It includes the operating system, application server, and applications, along with the mapping for attached block devices (EBS volumes or instance store). AMIs can be sourced from AWS (Quick Start AMIs), the AWS Marketplace (pre-packaged software), community-contributed, or custom-created from existing instances. This flexibility allows users to quickly deploy standardized environments, replicate production setups, and share golden images across teams or accounts.

AMI Components
AMI Categories and Sources
  1. 1

    Quick Start AMIs: Provided by AWS (e.g., Amazon Linux 2, Windows Server) with regular security updates, no additional charge beyond usage

  2. 2

    AWS Marketplace AMIs: Pre-packaged software from third-party vendors (e.g., WordPress, Jenkins) often with hourly license fees

  3. 3

    Community AMIs: Shared by other AWS users; use with caution as they may not be secure or updated

  4. 4

    Custom AMIs: Created from a running EC2 instance using create-image; ideal for golden images, disaster recovery, and consistent deployments

  5. 5

    Copyable AMIs: AMIs can be copied across regions and accounts, enabling global deployment and shared golden images

AMI Lifecycle and Best Practices
  1. 1

    Create AMI from running instance: Use aws ec2 create-image to capture the exact state of an instance, including data from attached EBS volumes

  2. 2

    Deregister AMI: Removes the AMI from your account, but does not delete the underlying EBS snapshots automatically; manage snapshots separately

  3. 3

    Deprecation Time: Set a deprecation time for old AMIs to warn or prevent usage after a certain date

  4. 4

    Cross-account Sharing: Use modify-image-attribute to share AMIs with specific AWS accounts, ideal for multi-account CI/CD pipelines

  5. 5

    Encryption: AMIs created from encrypted volumes automatically support encryption at rest; use AWS KMS keys for control

  6. 6

    Cost: You pay for EBS snapshots backing the AMI; cleaning up unused AMIs and snapshots reduces costs