Create an Amazon EBS-backed AMI
You can create your own Amazon EBS-backed AMI from an Amazon EC2 instance or from a snapshot of the root device of an Amazon EC2 instance.
To create an Amazon EBS-backed AMI from an instance, start by launching an instance using an existing Amazon EBS-backed AMI. This AMI can be one you obtained from the Amazon Web Services Marketplace, created using VM Import/Export, or any other AMI that you can access. After customizing the instance to meet your specific requirements, create and register a new AMI. You can then use the new AMI to launch new instances with your customizations.
The procedures described below work for Amazon EC2 instances backed by encrypted Amazon Elastic Block Store (Amazon EBS) volumes (including the root volume) as well as for unencrypted volumes.
The AMI creation process is different for instance store-backed AMIs. For more information, see Create an instance store-backed AMI.
Contents
Overview of AMI creation from an instance
The following diagram summarizes the process for creating an Amazon EBS-backed AMI from a running EC2 instance: Start with an existing AMI, launch an instance, customize it, create a new AMI from it, and finally launch an instance of your new AMI. The numbers in the diagram match the numbers in the description that follows.
- 1 – AMI #1: Start with an existing AMI
-
Find an existing AMI that is similar to the AMI that you'd like to create. This can be an AMI you have obtained from the Amazon Web Services Marketplace, an AMI that you have created using VM Import/Export, or any other AMI that you can access. You'll customize this AMI for your needs.
In the diagram, EBS root volume snapshot #1 indicates that the AMI is an Amazon EBS-backed AMI and that information about the root volume is stored in this snapshot.
- 2 – Launch instance from existing AMI
-
The way to configure an AMI is to launch an instance from the AMI on which you'd like to base your new AMI, and then customize the instance (indicated at 3 in the diagram). Then, you'll create a new AMI that includes the customizations (indicated at 4 in the diagram).
- 3 – EC2 instance #1: Customize the instance
-
Connect to your instance and customize it for your needs. Your new AMI will include these customizations.
You can perform any of the following actions on your instance to customize it:
-
Install software and applications
-
Copy data
-
Reduce start time by deleting temporary files and defragmenting your hard drive
-
Attach additional EBS volumes
-
- 4 – Create image
-
When you create an AMI from an instance, Amazon EC2 powers down the instance before creating the AMI to ensure that everything on the instance is stopped and in a consistent state during the creation process. If you're confident that your instance is in a consistent state appropriate for AMI creation, you can tell Amazon EC2 not to power down and reboot the instance. Some file systems, such as XFS, can freeze and unfreeze activity, making it safe to create the image without rebooting the instance.
During the AMI-creation process, Amazon EC2 creates snapshots of your instance's root volume and any other EBS volumes attached to your instance. You're charged for the snapshots until you deregister the AMI and delete the snapshots. If any volumes attached to the instance are encrypted, the new AMI only launches successfully on instances that support Amazon EBS encryption.
Depending on the size of the volumes, it can take several minutes for the AMI-creation process to complete (sometimes up to 24 hours). You might find it more efficient to create snapshots of your volumes before creating your AMI. This way, only small, incremental snapshots need to be created when the AMI is created, and the process completes more quickly (the total time for snapshot creation remains the same).
- 5 – AMI #2: New AMI
-
After the process completes, you have a new AMI and snapshot (snapshot #2) created from the root volume of the instance. If you added instance-store volumes or EBS volumes to the instance, in addition to the root device volume, the block device mapping for the new AMI contains information for these volumes.
Amazon EC2 automatically registers the AMI for you.
- 6 – Launch instance from new AMI
-
You can use the new AMI to launch an instance.
- 7 – EC2 instance #2: New instance
-
When you launch an instance using the new AMI, Amazon EC2 creates a new EBS volume for the instance's root volume using the snapshot. If you added instance-store volumes or EBS volumes when you customized the instance, the block device mapping for the new AMI contains information for these volumes, and the block device mappings for instances that you launch from the new AMI automatically contain information for these volumes. The instance-store volumes specified in the block device mapping for the new instance are new and don't contain any data from the instance store volumes of the instance you used to create the AMI. The data on EBS volumes persists. For more information, see Block device mappings for volumes on Amazon EC2 instances.
When you create a new instance from an EBS-backed AMI, you should initialize both its root volume and any additional EBS storage before putting it into production. For more information, see Initialize Amazon EBS volumes in the Amazon EBS User Guide.
Create an AMI from an instance
If you have an existing instance, you can create an AMI from this instance.
Create an AMI from a snapshot
If you have a snapshot of the root device volume of an instance, you can create an AMI from this snapshot.
Note
In most cases, AMIs for Windows, RedHat, SUSE, and SQL Server require correct
licensing information to be present on the AMI. For more information, see Understand AMI billing information. When creating an
AMI from a snapshot, the RegisterImage
operation derives the correct
billing information from the snapshot's metadata, but this requires the appropriate
metadata to be present. To verify if the correct billing information was applied,
check the Platform details field on the new AMI. If the field
is empty or doesn't match the expected operating system code (for example, Windows,
RedHat, SUSE, or SQL), the AMI creation was unsuccessful, and you should discard the
AMI and follow the instructions in Create an AMI from an instance.