AWS Amazon Machine Image (AMI)

Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.
Search for a command to run...

Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.
What is AWS EBS Snapshots? Amazon Web Services (AWS) Elastic Block Store (EBS) provides block-level storage volumes that can be thought of as virtual hard drives attached to EC2 instances running on AWS. An EBS snapshot is a point-in-time copy of you...
The git log command is used to view the commit history of a Git repository. You can customize the output format to show specific details in a more readable or structured way. Below are some useful variations and formatting options for git log: To sh...

Overview This article will teach us how to: Install Ubuntu Server 24.04 on a laptop from scratch Install Ubuntu server by using Vagrant tool with ISO image Prerequisites: A laptop without any OS installed; A virtualization software Virtualbox t...

The /etc/passwd and /etc/shadow files are the backbone of Linux user management. Together, they store user account information and handle authentication securely. This article provides a hands-on guide to understanding these files, their structure, a...

In Linux, links are powerful tools that allow you to create references to files and directories. There are two main types of links: hard links and soft links (also known as symbolic links or symlinks). Understanding the differences between these two ...

A hostname is a human-friendly name given to a computer. It is a unique identifier that allows us to identify the machine in various network communications, making it easier to locate and manage devices. Type: hostname To see where it is stored, typ...

AWS AMI stands for Amazon Machine Image. It is a pre-configured virtual machine image used to create virtual servers (instances) in the Amazon Elastic Compute Cloud (EC2). It includes the necessary information to launch an EC2 instance.
Create an AMI;
Register the AMI;
Use the AMI to launch new instances (if the AMI owner grants you launch permissions).
Copy an AMI within the same AWS Region or to different AWS Regions;
When you no longer require an AMI, you can deregister it. After you deregister an AMI, it can't be used to launch new instances. Existing instances launched from the AMI are not affected.

Contents of an AMI: An AMI typically contains:
A template for the root volume for the instance (e.g., an 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.
Public and Private AMIs: AMIs can be either:
Public: Owned by AWS or AWS Marketplace vendors and are available to all AWS customers.
Private: Owned by individual AWS accounts and are only available to that account (though they can be shared with specific accounts if desired).
Benefits:
Consistency: AMIs provide a predictable environment to deploy applications.
Speed: Since AMIs are pre-configured, new instances can be launched quickly.
Templating: If you have a specific setup or software stack that you want to replicate across multiple instances, you can create your own custom AMI.
Custom AMIs: Users can create their own AMIs, which is particularly useful if they need a consistent, reproducible environment. Once an EC2 instance is set up to the user's liking, it can be saved as a custom AMI, which can then be used to launch new instances with the same configuration.
Billing: Remember, while you aren't directly charged for the creation or storage of an AMI, you are billed for the Amazon S3 storage that the AMI takes up, and of course, for any EC2 instances you launch using that AMI.
In this hands-on lab, first, we will launch an EC2 instance (CreateCustomAMI) from an existing AMI Amazon Linux 2 AMI. Then, we will customize the instance by installing and starting an Apache web server, and then save this updated configuration as a custom AMI (MyCustomAMI). Next, we will create a second EC2 machine (UseCustomAMI), launch it with our previously created custom AMI MyCustomAMI and create a index.html file. It should appear on the browser.
Launch the EC2 CreateCustomAMI machine from an existing Amazon Linux 2 AMI, add a script that installs and starts Apache Web Server.

Then, access the instance via its public IP address to see whether the Apache server was installed and started correctly:


Create an image named MyCustomAMI from the EC2 instance CreateCustomAMI

Check whether the image was created and click "Launch instance from AMI" button to create a new second EC2 instance:

When launching a second EC2 instance UseCustomAMI , choose MyCustomAMI from My AMIs:

During the launch of the second EC2 machine, add the following user data which writes a new file:


Check whether the Apache server from custom AMI was installed by opening index.html file on the browser.
