Review load balancer attachment for an Auto Scaling group

Attach a load balancer when an Auto Scaling group needs request distribution.

Description

Check how requests reach an Auto Scaling group as instances start and stop. A queue worker that accepts no direct requests may not need a load balancer.

Potential impact

New instances may receive no traffic, or requests may continue reaching unhealthy instances.

Remediation

Set LoadBalancerNames to the Classic Load Balancer names or TargetGroupARNs to the target groups for an ALB or NLB. Configure listeners and health checks, then verify that new instances serve requests.

Examples

The second excerpt attaches WebAsg to the existing Classic Load Balancer web-elb. Supply a launch configuration source, such as a launch template, and the two referenced subnets.

Before

yaml
Resources:
  WebAsg:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      MinSize: "1"
      MaxSize: "4"
      DesiredCapacity: "2"
      VPCZoneIdentifier:
        - !Ref PublicSubnetA
        - !Ref PublicSubnetB

After

yaml
Resources:
  WebAsg:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      MinSize: "1"
      MaxSize: "4"
      DesiredCapacity: "2"
      LoadBalancerNames:
        - web-elb
      VPCZoneIdentifier:
        - !Ref PublicSubnetA
        - !Ref PublicSubnetB

References