Y NOT — Create Our Own Custom AMI and Launch EC2 Instances Using This AMI Across Regions

AMI (Amazon Machine Image) provides the information required to launch an EC2 instance. We must specify an AMI when we launch an instance. We can also create our own customized AMIs as well and make them private/public based on our needs. Default visibility of custom AMI is private.

We can customize an AMI based on our own software configuration, operation system, monitoring capabilities etc. Biggest advantage of using customized AMI is that it enables faster boot/configuration time because all our software are prepackaged.

AMI are built for a specific region and similar to snapshots of volumes, can be copied across regions.

We can launch an EC2 Instance from below three options

  • Public AMI provided by AWS (eg Amazon Linux V2, Ubuntu, Redhat etc)
  • Our Own AMI (we make and maintain them)
  • AWS Marketplace AMI (an AMI that someone else made and potentially being sold)

Step 1: Launch an EC2 Instance and set up user data scripts to install httpd service (Apache) and modify the index.html page to display host name. or more details on launching EC2 Instance, please feel to refer https://nagarajansivathanu.medium.com/y-not-launch-an-ec2-instance-in-aws-cloud-platform-dfddfe79b728

Install httpd service via user data scripts :

#Install httpd (Linux 2 Version)
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo “<h1> Hello World from $(hostname -f)</h1>” > /var/www/html/index.html

Step 2: Connect to EC2 Instance remotely via Putty and validate if httpd service is up and running part of EC2 Instance boot.

Step 3 : Create a custom AMI of this EC2 Instance (which has been bootstrapped to install httpd, kick start the httpd service on launch of EC2 Instance and modified the default index.html page to print host name).

Choosing the EC2 Instance, navigate to Actions → Image and templates → Create Image

Step 3: Verify the Images -> AMI section on the creation of our custom AMI

Step 4: Now if we launch another EC2 Instance, we should be seeing our custom AMIs under MyAMIs section as below

Step 5: I have launched an EC2 instance on ap-south-1b AZ from my custom AMI (which was created on ap-south-1a AZ of Mumbai Region)

Step 6 : Connect to EC2 Instance launched via custom AMI on ap-south-1b (diff AZ of Mumbai) remotely using Putty and validate the httpd service state


Step 7: To launch an EC2 Instance on different region (other than Mumbai) based on our custom AMI launched on Mumbai, first we need to copy the AMI as below

Step 8: Choose destination region where this AMI has to be copied

Step 9: After switching to Ohio Region, we should be able to see the custom AMI that has been copied from Mumbai region.

Following similar steps from Step 4 to Step 6, we can launch an EC2 Instance based out of our custom AMI on Ohio Region.

Hope you enjoyed this article!



A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store