Linn Linn Htun
Linn Linn Htun
AvatarLinn Linn Htun

AMI (Amazon Machine Image)

August 3, 2023

AMI (Amazon Machine Image)

An Amazon Machine Image (AMI) is a template that contains the software configuration — operating system, application server, and applications — needed to launch an EC2 instance. This post explains what AMIs are, how to create custom AMIs, the difference between public and private AMIs, and best practices for using AMIs to speed up deployments.

Amazon Machine Image (AMI)

  • AMI is a customization of an EC2 instance

    • you add your own software, configuration, operating system, monitoring, and so on

    • Faster boot/configuration time because all your software is pre-packaged

  • AMI is built for a specific region ( and can be copied across regions)

  • You can lunch EC2 instance from

    • A public AMI: AWS provided,

    • your own AMI: you make and maintain them yourself

    • An AWS marketplace AMI: an AMI someone else made (and potentially sell)

 

Hands-on

Click lunch instance button > choose Amazon Linux AWS > instance type t2 micro > key pair choose existing one > Network setting choose existing security group > 

Advance details : 

#!/bin/bash

# use this for your user data (script from top to bottom)

# install httpd (Linux 2 version)

yum update -y

yum install -y httpd

systemctl start httpd

systemctl enable httpd

echo "<h1>Hello world from $(hostname -f)</h1>"> /var/www/html/index.html

 

> click lunch instance > check your instance > click right click > image and template > create image > After put image name click create image button

 

 

How to use AMI?

AMI building an image in the instance. We can install software, packages and script as we want. We can reuse AMI image when we create next new instances.

Frequently Asked Questions

What is an Amazon Machine Image (AMI)?

An AMI is a pre-configured template for an EC2 instance that includes an operating system, application server, and any custom software, enabling you to launch identical instances quickly and consistently.

How do you create a custom AMI?

To create a custom AMI, launch an EC2 instance, configure it with your desired software and settings, then use the AWS Console or CLI to create an image from the running instance — AWS will stop the instance, snapshot the root volume, and register the AMI.