Skip to content

Latest commit

 

History

History
98 lines (55 loc) · 2.86 KB

project_4.md

File metadata and controls

98 lines (55 loc) · 2.86 KB

Deploy a simple website on ec2 instance with an application load balancer

  • Launch an Ec2 instance
  • enter the name of your instance
  • choose an AMI

type

  • create a key pair
  • select instance type

key

  • configure security group to allow connection on port 22 and 80 from anywhere-

sg


  • 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

login

  • note the ip address keeps changing as it is not static

home


Load Balancer with EC2

  • 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
  1. to get started, we will create a target group and select both instances

tg1

  1. the target group will perform health checks on the instances before allowing load balancer to route requests to it

tg

  1. we will configure our load balance to route request to both instances

  2. we will configure our instance to allow load balancer to route requests to it

lb

5.we will validate if it works or not

home

home2

it works!!