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.
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.
Contents
Register or deregister targets by instance ID
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.
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.
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.
Register or deregister targets using the AWS CLI
Use the register-targets command to add targets and the deregister-targets command to remove targets.