Register targets with your target group - Elastic Load Balancing

Register targets with your target group

You register your targets with a target group. When you create a target group, you specify its target type, which determines how you register its targets. For example, you can register instance IDs, IP addresses, or Lambda functions. For more information, see Target groups for your Application Load Balancers.

If demand on your currently registered targets increases, you can register additional targets in order to handle the demand. When your target is ready to handle requests, register it with your target group. The load balancer starts routing requests to the target as soon as the registration process completes and the target passes the initial health checks.

If demand on your registered targets decreases, or you need to service a target, you can deregister it from your target group. The load balancer stops routing requests to a target as soon as you deregister it. When the target is ready to receive requests, you can register it with the target group again.

When you deregister a target, the load balancer waits until in-flight requests have completed. This is known as connection draining. The status of a target is draining while connection draining is in progress.

When you deregister a target that was registered by IP address, you must wait for the deregistration delay to complete before you can register the same IP address again.

If you are registering targets by instance ID, you can use your load balancer with an Auto Scaling group. After you attach a target group to an Auto Scaling group and the group scales out, the instances launched by the Auto Scaling group are automatically registered with the target group. If you detach the target group from the Auto Scaling group, the instances are automatically deregistered from the target group. For more information, see Attaching a load balancer to your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

Target security groups

When you register EC2 instances as targets, you must ensure that the security groups for your instances allow the load balancer to communicate with your instances on both the listener port and the health check port.

Inbound
Source Port Range Comment
load balancer security group instance listener Allow traffic from the load balancer on the instance listener port
load balancer security group health check Allow traffic from the load balancer on the health check port

We also recommend that you allow inbound ICMP traffic to support Path MTU Discovery. For more information, see Path MTU Discovery in the Amazon EC2 User Guide for Linux Instances.

Shared subnets

Participants can create an Application Load Balancer in a shared VPC. Participants can't register a target that runs in a subnet that is not shared with them.

Register or deregister targets

The target type of your target group determines how you register targets with that target group. For more information, see Target type.

Register or deregister targets by instance ID

Note

When registering targets by instance ID for a IPv6 target group, the targets must have an assigned primary IPv6 address. To learn more, see IPv6 addresses in the Amazon EC2 User Guide for Linux Instances

The instance must be in the virtual private cloud (VPC) that you specified for the target group. The instance must also be in the running state when you register it.

To register or deregister targets by instance ID using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Load Balancing, choose Target Groups.

  3. Choose the name of the target group to open its details page.

  4. Choose the Targets tab.

  5. To register instances, choose Register targets. Select one or more instances, enter the default instance port as needed, and then choose Include as pending below. When you are finished adding instances, choose Register pending targets.

    Note:

    • The instances must have an assigned primary IPv6 address to be registered with a IPv6 target group.

    • AWS GovCloud (US) Regions don't support assigning a primary IPv6 address using the console. You must use the API to assign primary IPv6 addresses in AWS GovCloud (US) Regions.

  6. To deregister instances, select the instances and then choose Deregister.

Register or deregister targets by IP address

IPv4 targets

The IP addresses that you register must be from one of the following CIDR blocks:

  • The subnets of the VPC for the target group

  • 10.0.0.0/8 (RFC 1918)

  • 100.64.0.0/10 (RFC 6598)

  • 172.16.0.0/12 (RFC 1918)

  • 192.168.0.0/16 (RFC 1918)

You cannot register the IP addresses of another Application Load Balancer in the same VPC. If the other Application Load Balancer is in a VPC that is peered to the load balancer VPC, you can register its IP addresses.

IPv6 targets
  • The IP addresses that you register must be within the VPC CIDR block or within a peered VPC CIDR block.

To register or deregister targets by IP address using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Load Balancing, choose Target Groups.

  3. Choose the name of the target group to open its details page.

  4. Choose the Targets tab.

  5. To register IP addresses, choose Register targets. For each IP address, select the network, enter the IP address and port, and choose Include as pending below. When you are finished specifying addresses, choose Register pending targets.

  6. To deregister IP addresses, select the IP addresses and then choose Deregister. If you have many registered IP addresses, you might find it helpful to add a filter or change the sort order.

Register or deregister a Lambda function

You can register a single Lambda function with each target group. Elastic Load Balancing must have permissions to invoke the Lambda function. If you no longer need to send traffic to your Lambda function, you can deregister it. After you deregister a Lambda function, in-flight requests fail with HTTP 5XX errors. To replace a Lambda function, it is better to create a new target group instead. For more information, see Lambda functions as targets.

To register or deregister a Lambda function using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Load Balancing, choose Target Groups.

  3. Choose the name of the target group to open its details page.

  4. Choose the Targets tab.

  5. If there is no Lambda function registered, choose Register. Select the Lambda function and choose Register.

  6. To deregister a Lambda function, choose Deregister. When prompted for confirmation, choose Deregister.

Register or deregister targets using the AWS CLI

Use the register-targets command to add targets and the deregister-targets command to remove targets.