Amazon EC2 AMI Lifecycle (Part 2)
Create an Amazon EBS-backed
AMI
You can generate your own
Amazon EBS-backed AMI from an Amazon EC2 instance or a snapshot of the root
volume of an Amazon EC2 instance. To generate an Amazon EBS-backed AMI from an
instance, begin by launching an instance using an existing Amazon EBS-backed
AMI. This AMI could be one sourced from the AWS Marketplace, made through VM
Import/Export, or any other AMI that you have access to. After you modify the
instance to suit your particular needs, create and register a new AMI. You can
then utilize the new AMI to launch additional instances with your
modifications. The AMI creation process is different for instance store-backed
AMIs.
Overview of AMI creation
from an instance
The steps below outline
how to create an Amazon EBS-backed AMI from an active EC2 instance: Begin with
an existing AMI, start an instance, personalize it, generate a new AMI from
that instance, and ultimately launch an instance using your newly created AMI.
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 obtained from the AWS
Marketplace, an AMI created using VM Import/ Export, or any other AMI that you
can access.
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. Then, you'll create a new AMI that includes the
customizations.
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
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. During the AMI-creation
process, Amazon EC2 creates snapshots of your instance's root volume and any
other EBS volumes attached to your instance. 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).
AMI #2: New AMI-
After the process completes, you have a new AMI and snapshot 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.
Launch instance from new
AMI-
You can use the new AMI to launch an instance.
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.
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.
Comments
Post a Comment