Attach a load balancer to your Auto Scaling group - Amazon EC2 Auto Scaling
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Attach a load balancer to your Auto Scaling group

This topic describes how to attach an Elastic Load Balancing load balancer to your Auto Scaling group. Amazon EC2 Auto Scaling integrates with Elastic Load Balancing to help you to insert an Application Load Balancer, Network Load Balancer, Classic Load Balancer, or Gateway Load Balancer in front of your Auto Scaling group. To learn more about the different types of load balancers, see Elastic Load Balancing types.

When you attach an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer, you attach a target group. Amazon EC2 Auto Scaling adds instances to the attached target group when they are launched. You can attach one or multiple target groups, and configure health checks on a per target group basis.

For an introductory guide for attaching a target group to your Auto Scaling group, see Tutorial: Set up a scaled and load-balanced application.

Important

Before you continue, complete all prerequisites in the previous section.

Attach a load balancer

Use the following procedures to attach a load balancer to your Auto Scaling group. You can specify the load balancer by choosing either a target group that you created for an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer, or a Classic Load Balancer.

To attach an existing load balancer as you are creating a new Auto Scaling group
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/, and choose Auto Scaling Groups from the navigation pane.

  2. Choose Create Auto Scaling group.

  3. In steps 1 and 2, choose the options as desired and proceed to Step 3: Configure advanced options.

  4. For Load balancing, choose Attach to an existing load balancer.

  5. Under Attach to an existing load balancer, do one of the following:

    1. For Application Load Balancers, Network Load Balancers, and Gateway Load Balancers:

      Choose Choose from your load balancer target groups, and then choose a target group in the Existing load balancer target groups field.

    2. For Classic Load Balancers:

      Choose Choose from Classic Load Balancers, and then choose your load balancer in the Classic Load Balancers field.

  6. Proceed to create the Auto Scaling group. Your instances will be automatically registered to the load balancer after the Auto Scaling group has been created.

To attach an existing load balancer to your Auto Scaling group after it's created
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/, and choose Auto Scaling Groups from the navigation pane.

  2. Select the check box next to your Auto Scaling group.

    A split pane opens up in the bottom of the Auto Scaling groups page.

  3. On the Details tab, choose Load balancing, Edit.

  4. Under Load balancing, do one of the following:

    1. For Application, Network or Gateway Load Balancer target groups, select its check box and choose a target group.

    2. For Classic Load Balancers, select its check box and choose your load balancer.

  5. Choose Update.

Note

You can monitor the status of the load balancer while it is being attached by using the Amazon CLI. When Amazon EC2 Auto Scaling has successfully registered the instances and at least one registered instance passes the health checks, you receive a status of InService. For more information, see Verify the attachment status of your load balancer.

Detach a load balancer

When you no longer need the load balancer, use the following procedure to detach it from your Auto Scaling group.

To detach a load balancer from a group
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/, and choose Auto Scaling Groups from the navigation pane.

  2. Select the check box next to an existing group.

    A split pane opens up in the bottom of the Auto Scaling groups page.

  3. On the Details tab, choose Load balancing, Edit.

  4. Under Load balancing, do one of the following:

    1. For Application, Network or Gateway Load Balancer target groups, choose the delete (X) icon next to the target group.

    2. For Classic Load Balancers, choose the delete (X) icon next to the load balancer.

  5. Choose Update.