🎯 Objectives
Deploy 2 instances with different AZ
Install basic website on each instances
Create an Application Loadbalancer
Register both EC2 under the ALB
🔧 Prerequisites
Before you start, make sure you have:
An AWS account
Basic knowledge of EC2 instances
An Amazon Linux 2 AMI
An existing key pair & security group
🖥️ Step 1: Launch an EC2 Instance
(creating 2 instances)
Go to EC2 Dashboard → Launch Instance
Select Amazon Linux 2 AMI
Choose an instance type (I started with t3.micro)
Configure security group (allow HTTP (80), SSH (22), and HTTPS (443) if needed)
Launch and connect via SSH
*we hit on aws ec2 *
go to the network to change the subnet to 1a
Then launch
*Open another ec2 with the same way we can call it instance2 or webserver2
*
note we change network subnet in instance2 setup to 1b
Ensure the AZ are not the same
Then launched
*Already 2 intances running then we open our ClI (termus, gitbash or any goodone)
lets set both instance up in our Cli
For instance 1
Run our apache commands
sudo yum update -y
sudo yum install -y httpd
sudo systemctl start htppd
sudo systemctl enable httpd
lets test the server
we do the same setup on another Cli for instance2 apache2
instance2
installing Apache2
test apache2
Lets create our Application Load Balance
loadbalance > Targetgroup > create target group
select the instances
go to Loadbalancer > create Loadbalacer > create ALb
then we opt in for application Lb
Select the same Av zones in subnets of instance
ADD listener (the previous Tg)
🌐 Step 4: Test the Load Balancer
Copy the DNS name of your ALB and open it in the browser:
Or test using curl:
curl http://localhost
curl http://
curl http://
✅ Conclusion
We have successfully:
Launched two EC2 instances in different AZs
Installed Apache web servers
Configured an Application Load Balancer
Distributed traffic between both servers
This setup improves high availability and fault tolerance for your application 🚀