This article will help you gain a clear understanding of what Amazon Machine Images is and its inner workings. It is everything you need to understand about AWS AMIs. In simpler terms, It is a virtual image i.e., a template containing software configurations, including the operating system. They work as a blueprint for setting up an EC2 instance.
In this blog on What is Amazon Machine Image , we will read in detail about the following topics:
Check out this insightful AWS Tutorial to get you started on Amazon Web Services:
Let’s begin by understanding what Amazon Machine Image (AMI) is and how it helps in setting up an EC2.
What is an AMI?
AMI stands for Amazon Machine Image. The information required to launch an instance is provided by the Amazon Machine Image. AMI must be specified when an instance is launched. One AMI can be chosen to launch multiple instances when the configuration required is the same for all the instances. However, multiple AMIs can be used to launch instances with different configurations.
An AMI consists of the following:
- One or more EBS snapshots
- For instance-store-backed AMIs, a template for the root volume of the instance is provided. This includes the operating system, an application server, and applications.
- Launch permissions that control which AWS accounts can use the AMI to launch instances.
- A block device mapping that specifies the volumes to attach to the instance when it’s launched
AMIs are stored in the Amazon S3 and identified by a unique identifier in the form of AMI-xxxxxx and a manifest XML file. They can be created from scratch or bundled from existing EC2 instances. Once an AMI is created, it is stored in an S3 bucket and the user can decide whether to make it available to others users or keep it for personal use.
You can also associate a product code with a given AMI, thus, allowing the owner of the AMI to get revenue every time this AMI is used to create EC2 instances.
Looking to start a career in AWS? Read our guide on AWS Careers now!
Get 100% Hike!
Master Most in Demand Skills Now !
Key Terminology associated with AWS AMI
- EBS Snapshots – To successfully meet the challenges related to storing data in the cloud, Amazon provides a storage service to be used with your EC2 instances, called Amazon Elastic Block Storage or Amazon EBS.
- EC2 Instance – Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 eliminates your need to invest in hardware up-front so that you can develop and deploy applications faster.
- Amazon S3 – Amazon Simple Storage Service (Amazon S3) is storage for the Internet. It is designed to make web-scale computing easier.
Lifecycle of Amazon Machine Image (AWS AMI)
The above diagram gives the summary of the AMI Lifecycle. Once an AMI is created and registered, you can use it to launch new instances. AMI can be copied to the same as well as different AWS Regions. Once the AMI is no longer required, you can deregister it.
Few AMIs are provided by Amazon and you can search for an AMI that meets the criteria for your instance. Certain AMIs are also provided by the community. Once the AMI is selected, you can launch an instance. It works just like using any other server.
After an AMI is created, it can either be kept private or shared with a specific list of AWS accounts. Once your work with the AMI is completed, you can deregister the AMI. After deregistering, the AMI can’t be used to launch new instances but the existing instances that are already using AMI will not be affected.
Types of AMI Images
These are public-access machine images that are safe, secure, and customised.
These are images that a developer can sell to you. The images are available for purchase through the AWS Marketplace, an online store that offers software that runs on Amazon Web Services.
Only EC2 users who have been granted access to a private machine image by the developer can access it.
Types of AMI
Based on the following characteristics, the AMI can be selected.
- Regions – Each region is designed to be isolated from the other regions to achieve the greatest possible fault tolerance and stability. Your account will determine the regions that are available to you.
- Operating System – Operating system types like Linux, macOS, Raspbian, and Windows Server are provided by AWS for the user to choose from.
- Architecture – There is a choice between 32-bit and 64-bit for the user to choose between.
- Launch Permissions – The launch permissions determine the availability to be either public, explicit and implicit.
|public||The owner grants launch permissions to all AWS accounts.|
|explicit||The owner grants launch permissions to specific AWS accounts.|
|implicit||The owner has implicit launch permissions for an AMI.|
- backed by Amazon EBS – When AMI is categorized as backed by Amazon EBS it means that the root device for an instance launched from the AMAZON AMI is an Amazon Elastic Block Store (Amazon EBS) volume created from an Amazon EBS snapshot
- backed by instance store – When backed by instance store, it means that the root device for an instance launched from the AMI is an instance store volume created from a template stored in Amazon S3.
Since we have looked at the lifecycle and the types of the AMI, let’s now look at the best practices to build an Amazon Machine Image ( AWS AMI).
Go through our AWS Interview Questions and Answers blog if you are looking for a job on AWS!
Best Practices for Building AMI
This topic process helps you understand some of the best practices and references to help you build an Amazon Machine Images. The AMIs build and submitted to AWS Marketplace must adhere to all AWS Marketplace product policies.
- Always verify your AMI before submitting it as a new product or a version, you can use self-service scanning.
- Ensure that you secure reselling rights for non-free Linux distributions, with the exception of AWS-provided Amazon Linux, RHEL, SUSE, and Windows AMIs.
- Build AMIs using the most up-to-date operating systems, packages, and software.
- Create products from existing, well-maintained AMIs backed by Amazon Elastic Block Store (Amazon EBS) with a clearly defined lifecycle provided by trusted, reputable sources such as AWS Marketplace.
- Ensure that your AMI meets all AWS Marketplace policies, including disabling root login.
- Develop a repeatable process for building, updating, and republishing AMIs.
- Use a consistent operating system (OS) user name across all versions and products. We recommend ec2-user.
- Configure a running instance from your final AMI to the end-user experience you want, and test all installation methods, features, and performance before submission to AWS Marketplace.
- Check port settings as follows:
- Linux-based AMIs – Ensure that a valid SSH port is open. The default SSH port is 22.
- Windows-based AMIs – Ensure that an RDP port is open. The default RDP port is 3389. Also, the WinRM port (5985 by default) must be open to 10.0.0.0/16.
Pricing for Amazon Machine Images
You are not charged for creating the AMIs but you will be charged for the storage it takes.
- When an AMI is created and an instance of EC2 is attached to an EBS volume, the AMI will be made of snapshots of those EBS volumes. You are charged only for the storage space the EBS snapshots occupy.
- S3-backed AMIs will store data in S3 and hence, the price paid is that of the S3 storage fees.
Although, you can purchase a paid AMI from a developer. Integration with AWS Marketplace enables developers to charge other Amazon EC2 users for the use of their AMIs or to provide support for instances.
How to set up an AMI?
You can launch an instance from an existing AMI and then customize the instance to further save this configuration as a custom AMI.
The root volume of an instance is either an Amazon Elastic Block Store (Amazon EBS) volume or an instance store volume.
To create an Amazon EBS – backed AMI
You can create an AMI using the AWS Management Console or the command line. The above image summarizes the process for creating an Amazon EBS-backed AMI from a running EC2 instance.
For a better understanding of AWS, Check out our AWS Tutorial.
Here are the steps to create an AMI from an instance using the console.
- Select an appropriate EBS-backed AMI to serve as a starting point from your new AMI, and configure it as needed before launch.
- Choose Launch to launch an instance of the EBS-backed AMI that you prefer.
- While the instance is running, connect to it. You can perform actions on your instance such as:
- Installing software and applications
- Copy data
- Reduce start time by deleting temporary files, defragmenting your hard drive, and zeroing out free space
- Attach additional EBS volumes
- In the navigation pane, choose Instances, select your instance, and then click Actions, Image and templates, Create image.
- On the Create image page, specify the information required, and then choose to Create Image.
- To view the status of your AMI, click on the navigation pane and choose AMIs. Initially, the status is pending but should change to available after a few minutes.
- The new running instance contains all of the customizations that are applied in the previous steps.
Create an instance store-backed Linux AMI
The above image gives us a brief summary of how the instance store-backed Linux AMI is created.
- At first, you can launch an instance from an AMI that’s similar to the AMI that you’d like to create.
- Connect to your instance and customize it.
- Once the instance is set up, you can bundle it. The bundling process takes several minutes to complete.
- Once the process is completed, you have a bundle that consists of an image manifest (image.manifest.xml) and files (image.part.xx) that contain a template for the root volume.
- Next, you upload the bundle to your Amazon S3 bucket and then register your AMI.
Looking for the best AWS online training certification course? Intellipaat provides you with incredible AWS Certification led by top experts. Enroll with us today for a great hands-on experience!
Copying an AMI to another AWS region
As a prerequisite for copying an AMI, create or obtain an AMI backed by an Amazon EBS snapshot.
Now, let’s look at how to copy an AMI using the console.
- Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
- From the console navigation bar, select the Region that contains the AMI. In the navigation pane, choose Images, AMI’s to display the list of AMIs available to you in the Region.
- Select the AMI to copy and choose Actions, Copy AMI.
- In the Copy AMI dialog box, specify the required information and then choose Copy AMI.
An Amazon Machine Image (AMI) is a template that contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud. You can launch multiple instances of an AMI, as shown in the following figure. Your instances keep running until you stop, hibernate, or terminate them, or until they fail. If an instance fails, you can launch a new one from the AMI.
Having any doubt and wanting to clear it. Just go to our Intellipaat AWS Community and clear your doubts regarding AWS!