- Launch an Ec2 instance
- enter the name of your instance
- choose an AMI
- create a key pair
- select instance type
- configure security group to allow connection on port 22 and 80 from anywhere-
- paste in the user data to install neccesary package that powers our website
#!/bin/bash
# Elevate privileges to root
sudo -i
# Install required packages
yum update && yum install httpd wget unzip -y
# Start the Apache service and enable it to start automatically on boot
systemctl start httpd
systemctl enable httpd
# Download and extract the website template to a temporary directory
mkdir temp
cd temp
wget https://www.tooplate.com/zip-templates/2129_crispy_kitchen.zip
unzip 2129_crispy_kitchen.zip
# Copy the extracted files to the Apache document root directory
cp 2129_crispy_kitchen/* /var/www/html/
# Restart the Apache service to load the new website
systemctl restart httpd
- try connect to the instance with the public ip address and the key pair
- note the ip address keeps changing as it is not static
- we will 2 different website but will access them through load balancer
- application load balancer with route requests to either of the website as we refresh the page it will be dynamic
- switch from one site to another through one address
- to get started, we will create a target group and select both instances
- the target group will perform health checks on the instances before allowing load balancer to route requests to it
-
we will configure our load balance to route request to both instances
-
we will configure our instance to allow load balancer to route requests to it
5.we will validate if it works or not
it works!!