Create a target group for your Network Load Balancer
You register targets for your Network Load Balancer with a target group. By default, the load balancer sends requests to registered targets using the port and protocol that you specified for the target group. You can override this port when you register each target with the target group.
After you create a target group, you can add tags.
To route traffic to the targets in a target group, create a listener and specify the target group in the default action for the listener. For more information, see Listener rules. You can specify the same target group in multiple listeners, but these listeners must belong to the same Network Load Balancer. To use a target group with a load balancer, you must verify that the target group is not in use by a listener for any other load balancer.
You can add or remove targets from your target group at any time. For more information, see Register targets for your Network Load Balancer. You can also modify the health check settings for your target group. For more information, see Update the health check settings of a Network Load Balancer target group.
Requirements
-
All targets in a target group must have the same IP address type: IPv4 or IPv6.
-
You must use an IPv6 target group with a dualstack load balancer.
-
You can't use an IPv4 target group with a UDP listener for a
dualstack
load balancer.
To create a target group using the console
Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/
. -
In the navigation pane, choose Target Groups.
-
Choose Create target group.
-
For the Basic configuration pane, do the following:
-
For Choose a target type, select Instances to register targets by instance ID, IP addresses to register targets by IP address, or Application Load Balancer to register an Application Load Balancer as a target.
-
For Target group name, enter a name for the target group. This name must be unique per Region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.
-
For Protocol, choose a protocol as follows:
-
If the listener protocol is TCP, choose TCP or TCP_UDP.
-
If the listener protocol is TLS, choose TCP or TLS.
-
If the listener protocol is UDP, choose UDP or TCP_UDP.
-
If the listener protocol is TCP_UDP, choose TCP_UDP.
-
-
(Optional) For Port, modify the default value as needed.
-
For IP address type, choose IPv4 or IPv6. This option is available only if the target type is Instances or IP addresses.
You can't change the IP address type of a target group after you create it.
-
For VPC, select the virtual private cloud (VPC) with the targets to register.
-
-
For the Health checks pane, modify the default settings as needed. For Advanced health check settings, choose the health check port, count, timeout, interval, and specify success codes. If health checks consecutively exceed the Unhealthy threshold count, the load balancer takes the target out of service. If health checks consecutively exceed the Healthy threshold count, the load balancer puts the target back in service. For more information, see Health checks for Network Load Balancer target groups.
-
(Optional) To add a tag, expand Tags, choose Add tag, and enter a tag key and a tag value.
-
Choose Next.
-
On the Register targets page, add one or more targets as follows:
-
If the target type is Instances, select the instances, enter the ports, and then choose Include as pending below.
Note: The instances must have an assigned primary IPv6 address to be registered with a IPv6 target group.
-
If the target type is IP addresses, select the network, enter the IP addresses and ports, and then choose Include as pending below.
-
-
Choose Create target group.
To create a target group using the Amazon CLI
Use the create-target-group command to create the target group, the add-tags command to tag your target group, and the register-targets command to add targets.