AMI (Amazon Machine Image)
- An Amazon Machine Image (AMI) provides the information required to launch an instance.
- It act as a ISO file for the instance that is going to be launched.
- You must specify an AMI when you launch an instance.
- You can launch multiple instances from a single AMI when you need multiple instances with the same configuration.
- You can use different AMIs to launch instances when you need instances with different configurations.
AMI features
- AMIs are encrypted by default using the AWS Key Management Service (KMS).
- You can share AMIs with other AWS accounts or make them public.
- You can create an AMI from an instance and launch instances from the AMI.
- You can copy an AMI to another region and launch instances from the copied AMI.
Creating an AMI
- Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ (opens in a new tab).
- In the navigation pane, choose Instances.
- Select the instance from which you want to create an AMI.
- Choose Actions, Image and templates, Create image.
- Enter a Name and Description for the AMI.
- Choose Create image.
AMI vs. Launch Template
Feature | AMI (Amazon Machine Image) | Launch Template |
---|---|---|
Primary Purpose | Stores a pre-configured virtual machine image, including the OS, applications, and settings. Acts as the "content" of the instance. | Provides reusable configuration information for launching instances, such as instance type, network settings, and optional AMI reference. Acts as a "blueprint." |
Functionality | Acts as the "source" from which the instance's disk and OS are built. Comparable to an ISO or disk image. | Standardizes launch settings, supports versioning, and allows for consistent instance configurations. |
Required Inputs | Must specify an AMI every time you launch an instance unless included in a launch template or Auto Scaling group. | Can include AMI ID along with other configurations (e.g., instance type, key pairs, security groups) to streamline launches. |
Reusability | Can describe only the machine's disk state (OS, software, etc.). | Supports reusability with versioning, enabling different configurations (e.g., dev, staging, production) while referencing the same or different AMIs. |
Instance Configuration | Defines the OS, applications, and software environment of the instance. | Defines broader settings, including network, instance type, user data, and optionally the AMI. |
Launching Multiple Instances | You can launch multiple instances from a single AMI when the same configuration is required. | You can launch multiple instances from a single launch template with consistent settings, which can include referencing the same or different AMIs. |
Flexibility for Different Configurations | Use different AMIs to launch instances when varied configurations (e.g., OS or software) are needed. | Use different launch templates to standardize and manage varied instance configurations (e.g., dev vs. prod) while potentially using the same or different AMIs. |
Encryption | AMIs are encrypted by default if you enable default encryption for EBS volumes in your AWS account. | Launch templates themselves are not encrypted by default, but they can reference encrypted AMIs or volumes. |