AWS EC2 AMI Hands-On | A Step-by-Step Guide
Table of contents
Launch EC2 Instance
- To Launch the EC2 instance follow steps from Step-by-step guideline to launch EC2 Instance. However, ensure to update Step 6. Add User Data Script bash script with below.
#!/bin/bash
# Update the package repository and install Apache
yum update -y
yum install -y httpd
# Start the Apache service
service httpd start
# Enable Apache to start on system boot
systemctl enable httpd
We Launched a new EC2 instance
-
You can Go to PublicIP to test your running state of EC2 server
Create an Image
In the EC2 dashboard, locate and click on "Instance" in the left-hand sidebar under the "Instances" section.
Select your running Instance from Instances Interface's list
Go to "Actions"->"Image and Templates"->"Create Image"
Specify the name for the new image and then click the “Create Image” button.
You'll be redirected to Instances, with a notification that your image is created.
Launch Instance from AMI
In the EC2 dashboard, locate and click on "Instance" in the left-hand sidebar under the "Instances" section.
In the EC2 dashboard, click on the "Launch Instance" button
Select an "my AMIs" tab and select your AMI from the dropdown.
Select the instance type based on your workload requirements (e.g., t2.micro for a basic test) and key pair login from dropdown.
selecting an existing security group to control traffic to your instance.
Go to "Advance Settings" and all the way to the bottom paste user Data.
COPY
#!/bin/bash # Create a simple HTML page to verify Apache installation echo "<html><head><title>Test Page</title></head><body><h1>Apache is running!</h1></body></html>" > /var/www/html/index.html
This Time we are just Creating a web page, as rest of the boot script is already available in our AMI
Click "Launch" to initiate the instance creation process.
Once your instance is launched, you can monitor its status from the EC2 dashboard.
To access your instance, click on the "Instances" link in the navigation pane, then select your instance from the list.
From here, you can view details about your instance, including its public IP address and status.
To test the running instance go to http://<IP_address> or click of public IP above, just ensure it is http:// and not https://
Subscribe to my newsletter
Read articles from Divya Mahajan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Divya Mahajan
Divya Mahajan
Experienced Technical developer with 6+ years' global collaboration. Proficient in Python, Go, React, Next.js, Django, various databases, Cloud & DevOps (AWS EC2, Docker, Kubernetes), and Big Data tools. Skilled in data structures and algorithm, API development, and end-to-end software engineering. Excels in back-end development, front-end design, Root Cause Analysis, and product management to deliver superior user experiences. Holds a master’s degree in computer engineering.