top

Search

AWS Tutorials

AMI (Amazon Machine Image) provisions information required to launch an instance. An AMI needs to be specified when an instance is launched. But multiple instances can be launched with the help of a single AMI when multiple instances need the same configuration to run. Different AMIs are used to launch multiple instances when the configurations are different. An AMI consist of the following attributes: One or more EBS snapshots or a template for root volume of an instance (meant for the instance-store-backed AMIs). Launch permissions which help in controlling the AWS accounts that can use AMI to launch the instances.  A block device mapping that is used to specify volumes that need to be attached to the instance during its launch.  Using an AMIAn AMI lifecycle has been shown in the below snip:An AMI needs to be created and registered before it can be used to launch new instances.An AMI can be copied within the same region or to other regions based on its availability. When the user doesn’t require the AMI anymore, they can deregister it.  A specific AMI can be searched for that would match the user’s criteria for the specific instance. AMIs provided by community and AMIs provided by AWS can be searched for.Once an AMI has been used to launch an instance, the user can connect to it. Once the user is connected to the instance, it can be used like any other server.Creating an AMIAn instance can be launched with the help of an already present AMI, customize the instance, and save this updated configuration as a custom AMI. When instances are launched from this new custom AMI, the updated changes are reflected in it. The root storage device of an instance determines which process needs to be followed to create an AMI. The root volume of an instance can be an Amazon EBS volume or an instance store volume.  Creating an instance Store-backed Linux AMI:The below image shows how an AMI can be created with the help of an instance store-backed instance:Launch an instance from AMI.Connect to the instance and customize it if required.When the instance is ready to be launched, bundle it, which will take some time. It consists of an image manifest and files which contain template for the root volume.Once the process is complete, upload the bundle to Amazon S3 bucket and register the AMI with the instance.When an instance is launched with the AMI, the root volume is created for that instance with the help of the bundle which was uploaded to Amazon S3.The storage space used by the bundle on Amazon S3 is chargeable.If instance store volumes are added to the user instance along with the root device volume, the block device mapping for the new AMI will hold information for both these volumes.The block device mappings will automatically contain information for the volumes.Creating a Linux AMI from an instanceAn AMI can be created with the help of AWS Management Console as well as AWS CLI.The below image shows how a Linux AMI can be created from an instance:An appropriate EBS backed AMI has to be selected as a starting point to create the new AMI and configure it as required before launching it.Click on ‘Launch’ to launch an instance which has been selected. The default values have to be accepted via the wizard.When the instance is running, it needs to be connected and the below mentioned operations can be performed to customize it:Copying data.Installing software and applications.Reducing start time since temporary files will be deleted, and hard drive will be defragmented.Additional Amazon EBS volumes can be attached.This is an optional step- Create snapshots of all the volumes which are attached to the instance.In the navigation pane, click on the ‘Instances’, select the instance, click on ‘Action’, ‘Image’, ‘Create Image’.In the ‘Create Image’ dialog box, specify the ‘Image name’, ‘Image description’, ‘No reboot’ as ‘No’ and the ‘Instance Volume’. Now click on ‘Create Image’.The AMI takes a while to get created. To view its status, click on ‘AMIs’. The status is initially ‘pending’ and then goes to ‘available’ once it is successfully created.
logo

AWS Tutorials

How to use Amazon Machine Image (AMI)?

AMI (Amazon Machine Image) provisions information required to launch an instance. An AMI needs to be specified when an instance is launched. But multiple instances can be launched with the help of a single AMI when multiple instances need the same configuration to run. Different AMIs are used to launch multiple instances when the configurations are different. 

An AMI consist of the following attributes: 

  • One or more EBS snapshots or a template for root volume of an instance (meant for the instance-store-backed AMIs). 
  • Launch permissions which help in controlling the AWS accounts that can use AMI to launch the instances.  
  • A block device mapping that is used to specify volumes that need to be attached to the instance during its launch.  

Using an AMI

An AMI lifecycle has been shown in the below snip:

Using an AMI

  • An AMI needs to be created and registered before it can be used to launch new instances.
  • An AMI can be copied within the same region or to other regions based on its availability. 
  • When the user doesn’t require the AMI anymore, they can deregister it.  A specific AMI can be searched for that would match the user’s criteria for the specific instance. AMIs provided by community and AMIs provided by AWS can be searched for.
  • Once an AMI has been used to launch an instance, the user can connect to it. Once the user is connected to the instance, it can be used like any other server.

Creating an AMI

An instance can be launched with the help of an already present AMI, customize the instance, and save this updated configuration as a custom AMI. When instances are launched from this new custom AMI, the updated changes are reflected in it. The root storage device of an instance determines which process needs to be followed to create an AMI. The root volume of an instance can be an Amazon EBS volume or an instance store volume.  

Creating an instance Store-backed Linux AMI:

The below image shows how an AMI can be created with the help of an instance store-backed instance:

Creating an instance Store-backed Linux AMI

  • Launch an instance from AMI.
  • Connect to the instance and customize it if required.
  • When the instance is ready to be launched, bundle it, which will take some time. It consists of an image manifest and files which contain template for the root volume.
  • Once the process is complete, upload the bundle to Amazon S3 bucket and register the AMI with the instance.
  • When an instance is launched with the AMI, the root volume is created for that instance with the help of the bundle which was uploaded to Amazon S3.
  • The storage space used by the bundle on Amazon S3 is chargeable.
  • If instance store volumes are added to the user instance along with the root device volume, the block device mapping for the new AMI will hold information for both these volumes.
  • The block device mappings will automatically contain information for the volumes.

Creating a Linux AMI from an instance

An AMI can be created with the help of AWS Management Console as well as AWS CLI.

The below image shows how a Linux AMI can be created from an instance:

Creating a Linux AMI from an instance

An appropriate EBS backed AMI has to be selected as a starting point to create the new AMI and configure it as required before launching it.

Click on ‘Launch’ to launch an instance which has been selected. The default values have to be accepted via the wizard.

When the instance is running, it needs to be connected and the below mentioned operations can be performed to customize it:

  • Copying data.
  • Installing software and applications.
  • Reducing start time since temporary files will be deleted, and hard drive will be defragmented.
  • Additional Amazon EBS volumes can be attached.

This is an optional step- Create snapshots of all the volumes which are attached to the instance.

In the navigation pane, click on the ‘Instances’, select the instance, click on ‘Action’, ‘Image’, ‘Create Image’.

In the ‘Create Image’ dialog box, specify the ‘Image name’, ‘Image description’, ‘No reboot’ as ‘No’ and the ‘Instance Volume’. Now click on ‘Create Image’.

The AMI takes a while to get created. To view its status, click on ‘AMIs’. The status is initially ‘pending’ and then goes to ‘available’ once it is successfully created.

Leave a Reply

Your email address will not be published. Required fields are marked *