Create An Application Load Balancer For The VPC

                               APPLICATION LOAD BALANCER FOR THE VPC










Step 1 : First create a VPC 




Fill the required details like name tag , IPV4 CIDR as "10.0.0.0/16" and  click create VPC



STEP 2 : Create 4 subnets (2 public subnets in different regions ) and (2 private subnets in different regions)

Public subnet 1 and 2

Private subnet 1 and 2


    4 subnets have successfully created 



STEP 3: Create a Internet Gateway named as "my-internet" 


   Attach the internet gateway to your VPC 










STEP 4 : Create a NAT Gateway 

Fill the details name , give the subnet as "public 1" and allocate elastic IP 




STEP 5: Choose Route tables in categories , and click your VPC route table and choose edit
routes and In subnet associations choose edit and give your public subnets , click save changes.





Add route and give target to your "Internet gateway"




Create another route table for NAT gateway 



In subnet associations choose edit and give your 2 private subnets , click save changes.





In NAT route table ,Choose edit routes and give target as "NAT gateway" address


 STEP 6: In EC2 instances ,create 2 instances and launch it .


Navigate to advanced details tab and paste the following in the user data text area

add this 

#!/bin/bash
yum install httpd -y
systemctl enable httpd
echo “<h1>This is instance 2</h1>” >/var/www/html/index.html
systemctl start httpd



Create another instance with different private subnet. Select the same security group that was previously created for the first instance.

 
STEP 7:Create a application load balancer 



And choose the vpc created by you ,map the public subnets created.


Create security group and add the inbound rules:







create a target groups and choose two instaces then click include as pending below and click register target groups



Choose the target group created in the load balancer tab. Then click on create Load balancer.

Navigate to the ec-2 to security group that was created earlier and edit the inbound rules. Add the load balancer security group which was created for the load balancer.


Then to tareget groups and see the status as "helathy" and then open load balancer copy the dns paste in the website 



If the Load balancer is working fine ,the browser displays the default page of your server.





 

Comments