Application-Load balancer
Creation of application load balancer for VPC the pre-requisites that are required for this application load balancer are
- An AWS account
- First in order to create a load balancer we need a VPC with different subnets associated with different regions so go ahead and first create a VPC first with following configurations.
2. Now I am going to create four subnets where I use each of two subnets as private and public respectively with different regions for each of them in private and public respectively go to subnets section in your AWS console and click on create subnet enter the configurations as given in the below
Similarly create a private table the only difference here is we add nat gateway route instead to IGW gateway.
5. The next step is to map this tables to the respective subnets which can done using the option edit subnet association option.
6. Now it time to create Ec-2 instances for our private subnets so head over to ec-2 dashboard and click create instance name the instances and in network settings tab click on edit change the VPC to the one we have created now and also assign private subnet in the subnet section as follows.
Now navigate to advanced details tab and paste the following in the user data text area.
Note for another instance with different private subnet use the below code to differentiate ec-2 instances that are connected to a load balancer.
You can use the same security that you previously created for the first instance here also.
7. Now its time to head to our load balancer section and click on create load balancer choose application load balancer use the following configurations as given in the images.
In security groups tab click on create new a add the following inbound rules.
Now choose this security group in the load balancer tab In listeners and routing section create a new target group and add the ec2s previously created into the target group leave the group details section as such and proceed to register targets.
I am adding the LBSG security group which is new security group that was created for the load balancer to Sg-1 (ec-2 security group) save the changes and look into health status of target group by navigating that respective section once the status of the instances become healthy you are ready to test the load balancer.
Navigate to load balancer tab and copy the DNS name, paste the URL in a new tab.
You will notice the following website with the following pages after successive reloads now we can confirm that our load balancer is working as expected.
Comments
Post a Comment