Cloud Migration: Pt 2 — Creating AMI using an EC2 instance

Troy Dash
4 min readJul 17, 2024

--

Overview

This is the 2nd of a 5 part series that will cover:

  1. Webserver creation — EC2 instance with Apache setup.
  2. Creating an AMI using the EC2 instance we created.
  3. Leveraging AWS CLI to do the same. (EC2 & AMI Creation)
  4. Accessing Amazon RDS & S3 securely using our EC2 instance.
  5. Leveraging Elastic Load Balancing (ELB) & Auto Scaling Groups (ASG) with our EC2 instance.

Part 1

Use Case / Scenario

The Level-Up Bank aims to enhance the scalability, reliability, and security of its website and online banking platform by migrating to the cloud using AWS. The bank creates a t2.micro EC2 instance running an Apache web server, starting with an AWS account setup and selecting the appropriate AMI. A user-data script updates packages, installs Apache, and starts the service. The Apache installation is verified through the public IP. Migration includes leveraging AWS services like Amazon RDS and S3 for a secure environment. The bank can scale EC2 instances based on demand, using Elastic Load Balancing and Auto Scaling. This migration aims to improve the bank’s online presence and provide a secure, reliable platform for customers.

Prerequisites

  1. AWS Account
  2. Basic Understanding of Networking, Linux & AWS navigation
  3. Patience

Problem / Issue

We need to accomplish the feat of creating a AMI using an existing EC2 instance and to that end we will cover:

  1. Creating an AMI through CloudShell

Solution

Creating an AMI through CloudShell

We will need to grab our instance id (you can find this on the instances page of the EC2 app) and plug it into the command below in the cloud shell. You can open the cloud shell by being logged into your AWS account and clicking on the highlighted icon.

What is CloudShell?

AWS CloudShell is a browser-based shell that provides a pre-configured environment with the AWS CLI, SDKs, and development tools, which ultimately rids the need for local setup. It offers a persistent home directory with some storage, allowing you to save scripts and files between sessions. To that end we will be using it to run a command that will create our AMI.

Cloud Shell Link

We can open cloud shell by clicking the icon at the top of our AWS Console.

More on CloudShell

Cloud Shell AMI Creation Command Structure

aws ec2 create-image --instance-id "your instance id" --name "My server" --no-reboot

Collecting Information for our CloudShell Command

Since we only need our instance ID navigating to the the instances page on the EC2 app will show us all of our instances and our instance ids in thier column.

Example Cloud Shell AMI Creation Command

aws ec2 create-image --instance-id i-05d385f2c3206ef03 --name "My-First-AMI" --no-reboot

Creating our AMI

After inputting the command and executing it with the return key we can see the id of the image we created and navigating to the AMI page shows us our creation.

Success! This brings us roughly to the end of this document. I have also included a “Challenges” section where I would mention any hurdles that I ran into during this process. This time around I will see if any of you ran into anything via the comments and ill adjust the article as needed in the future.

Challenges:

N/A

--

--