2

We know that in order to attach an Application/Network load balancer for an auto-scaling group, we need to attach the target group(s) to the existing Auto-scaling group in order to distribute the load. In the case of the Classic Load Balancer, we directly attach the load balancer to the ASG but in case of an ALB, we do it through the target groups consisting of targets which can be either an instance, IP or a lambda function.

My question is, are the instances in these target groups defined for an ALB and the instances in ASG different? Or are they the same? If they are the same, then do we have to create a new target group again with targets defined as the EC2 instances in ASG? I can't understand the mapping of instances in target-groups to the instances in ASG. I went through the documentation for attaching a load balancer to an existing ASG, but all it says is to select an existing target group.

Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
Jarvis
  • 8,494
  • 3
  • 27
  • 58

1 Answers1

3

Are the instances in these target groups defined for an ALB and the instances in ASG different? Or are they the same?

They are the same.

ELB -> Target Group -> EC2 (without ASG)

ELB -> Target Group -> ASG -> EC2 (with ASG).

Please read the link below for details.

If they are the same, then do we have to create a new target group again with targets defined as the EC2 instances in ASG

This quote from the AWS document. We need to add ASG to ELB, then AWS takes care of the rest.

When you use your Elastic Load Balancing load balancer with an Auto Scaling group, it's not necessary to register your EC2 instances with the load balancer or target group. With Elastic Load Balancing, instances that are launched by your Auto Scaling group are automatically registered with the load balancer or target group, and instances that are terminated by your Auto Scaling group are automatically deregistered from the load balancer or target group

Ref: https://docs.aws.amazon.com/autoscaling/ec2/userguide/autoscaling-load-balancer.html

Tuan Vo
  • 1,875
  • 10
  • 10