AWS-load balancer Creation with listener rules and target resources

Ammar Suhail
5 min readJul 11, 2023

--

Step 1: Sign in to the AWS Management Console.

Step 2: Open the EC2 service.

Step 3: In the navigation pane, under Load Balancing, select Load Balancers.

Step 4: Click on the “Create Load Balancer” button.

Step 5: Choose the “Application Load Balancer” option.

Step 6: Configure the basic settings for your ALB:

  • Give your ALB a name.
  • Select the appropriate VPC where you want to deploy the ALB.
  • Choose the availability zones for your ALB.
  • Select the “Internet-facing” or “Internal” option based on your requirements.

Step 7: Configure the listeners for your ALB:

  • Specify the port and protocol for your listener. For example, you can choose HTTP on port 80.
  • You can add additional listeners based on your application’s needs.

Step 8: Configure the routing for your ALB:

  • Create a new target group or choose an existing one. The target group determines how traffic is distributed to your instances.
  • Configure health checks to ensure the instances are healthy.

Step 9: Configure security settings:

  • Select an existing security group or create a new one for your ALB.
  • Specify the ports and protocols that you want to allow inbound traffic for.

Step 10: Review the configuration and click on the “Create” button.

Once the ALB is created, you will be able to see its details and configuration. You can obtain the DNS name of the ALB, which you can use to access your application.

Remember that you will also need to configure your instances to be part of the target group associated with the ALB so that they can receive traffic from it. You can do this by either registering instances manually or using an Auto Scaling group.

Create a vpc with subnets in two AZ with following resources

create following EC2 machines with public IP with SG assigned rules: 80/22

To configure a load balancer and target groups in AWS, you can follow these steps:

Step 1: Sign in to the AWS Management Console.

Step 2: Open the EC2 service.

Step 3: In the navigation pane, under Load Balancing, select Load Balancers.

Step 4: Click on the “Create Load Balancer” button.

Step 5: Choose the appropriate type of load balancer based on your requirements, such as Application Load Balancer (ALB) or Network Load Balancer (NLB).

Step 6: Configure the basic settings for your load balancer:
— Give your load balancer a name.
— Select the appropriate VPC where you want to deploy the load balancer.
— Choose the availability zones for your load balancer.
— Select the “Internet-facing” or “Internal” option based on your requirements.

Step 7: Configure the listeners for your load balancer:
— Specify the port and protocol for your listener. For example, you can choose HTTP on port 80.
— You can add additional listeners based on your application’s needs.

Step 8: Configure the routing for your load balancer:
— Create a new target group or choose an existing one. The target group determines how traffic is distributed to your instances.
— Specify the target type, which can be instances, IP addresses, or Lambda functions.
— Configure health checks to ensure the instances are healthy.

Step 9: Configure security settings:
— Select an existing security group or create a new one for your load balancer.
— Specify the ports and protocols that you want to allow inbound traffic for.

Step 10: Review the configuration and click on the “Create” button.

Once the load balancer is created, you will be able to see its details and configuration. You can obtain the DNS name of the load balancer, which you can use to access your application.

To configure the target groups associated with your load balancer, follow these steps:

Step 1: In the EC2 service, go to the navigation pane, under Load Balancing, select Target Groups.

Step 2: Click on the “Create target group” button.

Step 3: Configure the target group settings:
— Give your target group a name.
— Select the target type based on your load balancer’s requirements.
— Specify the protocol and port that the target group will use to communicate with the instances.
— Configure health checks to ensure the instances are healthy.

Step 4: Review the configuration and click on the “Create” button.

Once the target group is created, you can register instances with it. You can do this manually or by using an Auto Scaling group. When instances are registered with the target group, they become part of the load balancer’s routing configuration.

Remember to properly configure the instances and ensure they are running the necessary services to receive and respond to traffic from the load balancer.

In ec2 machines add following lines to check webserver

yum update -y
yum install httpd -y
systemctl start httpd
systemctl enable httpd
cd /var/www/html

echo ‘<p> Hello welcome to Cloud Journey with Ammar<p> This is machine 1</h1>’ >index.html

just change machine with 2,3,4 respectively for different ec2 machines

Target group verification is possible through this DNS

FINAL: Clean up all resources to avoid heavy costs

If you folks find any difficulties to perform the labs. kindly mail me at ammarsuhail153@gmail.com. I would be Happy to help.

GitHub repository — https://github.com/CloudOps2029

I hope you liked this article. if you find this article helpful then kindly give feedback and also follow me for more, and also do let me know about the topic of next Blog.

— — — — — — THANK YOU_________

--

--

Ammar Suhail
Ammar Suhail

Written by Ammar Suhail

DevOps/ Cloud Engineer/AWS Certified/ CKAD Certified/ Terraform Certified/M.S Electrical & Computer Engineering (USA)

No responses yet