1

I have a basic question with respect to how a load balancer works. I have a VPC created with 3 subnets one in each availability zone(us-west-2a,us-west-2b,us-west-2c) and a 4th subnet in the same availability zone us-west-2a.

Now when I enable Availability Zones for the load balancer, I enable it in us-west-2a,us-west-2b,us-west-2c (subnet1, subnet2, subnet3).

I also have instances running in subnet 4 in us-west-2a. How to enable the load load balancer route traffic to instances in the 4th subnet? Any thoughts?

fledgling
  • 991
  • 4
  • 25
  • 48
  • Just add the instance to your target group. Nothing special needs to be done. – Marcin May 19 '20 at 02:34
  • adding the vpcId to the target group - makes it work? – fledgling May 19 '20 at 02:42
  • You register instances with target groups using [instance-id](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#target-type). Not sure what do you mean by VPCId? Do you have custom vpc? – Marcin May 19 '20 at 02:44
  • My TargetType is `ip` and yes it is a custom vpc and not a default vpc. – fledgling May 19 '20 at 02:50
  • Instances should use instance-id, not ip. But anyway, it doesn't work? – Marcin May 19 '20 at 02:51
  • My question was if I only enable AZs specific to 3 subnets, how does the LB know to route to the 4th subnet. I am not sure if it will work. Wanted to check the behavior – fledgling May 19 '20 at 03:02
  • It will know because it will be register in the target group which is connected to the LB. Without being registers, LB will not route traffic to any instance. – Marcin May 19 '20 at 03:04

1 Answers1

2

Based on the comments and chat discussion.

The question arises from confusion between subsets selected when one creates NLB, and subsets used by instances.

Since the OP has enabled 3 subnets in 3 AZs (us-west-2a,us-west-2b,us-west-2c; one subnet per AZ) for the NLB, instances can be in any subset withing these zones and same VPC. The instances do not have to be in the same subnets as the NLB.

Therefore, since the 4th subnet is in us-west-2a, instances created in this subnet need to be only registers with a target group used by NLB.

Marcin
  • 215,873
  • 14
  • 235
  • 294