register_targets
async
¶
register_targets(
*,
config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = 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.
>>> await 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.
>>> await 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/async_elastic_load_balancingv2.py
3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 | |