register_targets
¶
register_targets(
*,
config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
target_group_arn: Optional[TargetGroupArn] = None,
targets: Optional[TargetDescriptions] = None,
) -> RegisterTargetsOutput
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.
For more information, see the following:
Parameters:
-
target_group_arn(Optional[TargetGroupArn], default:None) –The Amazon Resource Name (ARN) of the target group.
-
targets(Optional[TargetDescriptions], default:None) –The targets.
Raises:
-
InvalidTargetException–The specified target does not exist, is not in the same VPC as the target group, or has an unsupported instance type.
-
TargetGroupNotFoundException–The specified target group does not exist.
-
TooManyRegistrationsForTargetIdException–You've reached the limit on the number of times a target can be registered with a load balancer.
-
TooManyTargetsException–You've reached the limit on the number of targets.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To register targets with a target group This example registers the specified instances with the specified target group.
>>> client.register_targets(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067', targets=[{'Id': 'i-80c8dd94'}, {'Id': 'i-ceddcd4d'}])
To register targets with a target group using port overrides
This example registers the specified instance with the specified target group using multiple ports. This enables you to register ECS containers on the same instance as targets in the target group.
>>> client.register_targets(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9', targets=[{'Id': 'i-80c8dd94', 'Port': 80}, {'Id': 'i-80c8dd94', 'Port': 766}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 | |