Registers the specified targets with the specified target group.
If the target is an EC2 instance, it must be in the running
state when you register it.
By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports.
With a Network Load Balancer, you cannot register instances by instance ID if they have the following instance types: C1, CC1, CC2, CG1, CG2, CR1, CS1, G1, G2, HI1, HS1, M1, M2, M3, and T1. You can register instances of these types by IP address.
To remove a target from a target group, use DeregisterTargets .
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
register-targets
--target-group-arn <value>
--targets <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--cli-auto-prompt <value>]
--target-group-arn
(string)
The Amazon Resource Name (ARN) of the target group.
--targets
(list)
The targets.
To register a target by instance ID, specify the instance ID. To register a target by IP address, specify the IP address. To register a Lambda function, specify the ARN of the Lambda function.
(structure)
Information about a target.
Id -> (string)
The ID of the target. If the target type of the target group is
instance
, specify an instance ID. If the target type isip
, specify an IP address. If the target type islambda
, specify the ARN of the Lambda function.Port -> (integer)
The port on which the target is listening. Not used if the target is a Lambda function.
AvailabilityZone -> (string)
An Availability Zone or
all
. This determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.This parameter is not supported if the target type of the target group is
instance
.If the target type is
ip
and the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.With an Application Load Balancer, if the target type is
ip
and the IP address is outside the VPC for the target group, the only supported value isall
.If the target type is
lambda
, this parameter is optional and the only supported value isall
.
Shorthand Syntax:
Id=string,Port=integer,AvailabilityZone=string ...
JSON Syntax:
[
{
"Id": "string",
"Port": integer,
"AvailabilityZone": "string"
}
...
]
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--cli-auto-prompt
(boolean)
Automatically prompt for CLI input parameters.
See ‘aws help’ for descriptions of global parameters.
Example 1: To register targets with a target group by instance ID
The following register-targets
example registers the specified instances with a target group. The target group must have a target type of instance
.
aws elbv2 register-targets \
--target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067 \
--targets Id=i-1234567890abcdef0 Id=i-0abcdef1234567890
Example 2: To register targets with a target group using port overrides
The following register-targets
example registers the specified instance with a target group using multiple ports. This enables you to register containers on the same instance as targets in the target group.
aws elbv2 register-targets \
--target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-internal-targets/3bb63f11dfb0faf9 \
--targets Id=i-0598c7d356eba48d7,Port=80 Id=i-0598c7d356eba48d7,Port=766
Example 3: To register targets with a target group by IP address
The following register-targets
example registers the specified IP addresses with a target group. The target group must have a target type of ip
.
aws elbv2 register-targets \
--target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-ip-targets/8518e899d173178f \
--targets Id=10.0.1.15 Id=10.0.1.23
Example 4: To register a Lambda function as a target
The following register-targets
example registers the specified IP addresses with a target group. The target group must have a target type of lambda
. You must grant Elastic Load Balancing permission to invoke the Lambda function.
aws elbv2 register-targets \
--target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-ip-targets/8518e899d173178f \
--targets Id=arn:aws:lambda:us-west-2:123456789012:function:my-function
None