How to Create Target Groups for load balancer on Amazon Web Service(AWS).

A target group tells a load balancer where to direct traffic to : EC2 instances, fixed IP addresses; or AWS Lambda functions, amongst others. When creating a load balancer, you create one or more listeners and configure listener rules to direct the traffic to one target group.

The port the load balancer uses when performing health checks on targets. If the protocol is HTTP, HTTPS, TCP, TLS, UDP, or TCP_UDP, the default is traffic-port , which is the port on which each target receives traffic from the load balancer. If the protocol is GENEVE, the default is port 80.

 

  • Login to aws portal.
  • Click on Services.

 

Fig 1

 

  • Under Compute select EC2.

 

Fig 2

 

  • Click on Target Groups.

 

Fig. 3

 

  • Click on Create Target Group.

 

Fig. 4

 

  • Provide Target group name.
  • Select Target type :Instance ,IP(Network load balancer) or Lambda function(An application).Select Instance Target type for application load balancer.
  • Select Protocol like HTTP, HTTPs, TCP or UDP. The protocol load balancer uses when routing traffic to targets in this target group.
  • Provide Port Number, Load balancer port uses when routing traffic to targets in this target group (1-65535).
  • Select existing VPC.
  • Then select protocol for health check settings, The protocol of load balancer uses when performing health checks on targets in this target group.
  • Set the path for health checks.

 

Fig. 5

 

 

  • At Advanced health check settings, Select port:traffic port or override.

 

  • Provide healthy threshold & Unhealthy threshold.
  • If health checks consecutively exceed the Unhealthy threshold count then the load balancer takes the target out of service. If health checks consecutively exceed the Healthy threshold count, the load balancer puts the target back in service.
  • Set Timeout and the amount of time in seconds during which no response means a failed health check (2-120 seconds)
  • Set the Interval and the approximate amount of time between health checks of an individual target (5-300 seconds).
  • Set the success code and the HTTP codes use when checking for a successful response from a target.
  • Then click on Create.

 

Fig. 7

 

  • After sometime target group is ready.

 

Fig. 8

 

Create Target Group using Shell

  1.  To create a target group to route traffic to instances registered by instance ID.

aws elbv2 create-target-group –name example  –protocol HTTP  –port 80  –target-type instance –vpc-id vpc_id

 

2.  To create a target group to route traffic to an IP addresses.

aws elbv2 create-target-group –name example  –protocol TCP  –port 80  –target-type ip  –vpc-id vpc_id

 

3.  To create a target group to route traffic to a Lambda function.

aws elbv2 create-target-group  –name example –target-type lambda

 

Leave a Reply