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:
An AMI lifecycle has been shown in the below snip:
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.
The below image shows how an AMI can be created with the help of an instance store-backed 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:
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:
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.