Skip to content

register_instances_with_load_balancer async

register_instances_with_load_balancer(
    load_balancer_name: AccessPointName,
    instances: Instances,
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
) -> RegisterEndPointsOutput

Adds the specified instances to the specified load balancer.

The instance must be a running instance in the same network as the load balancer (EC2-Classic or the same VPC). If you have EC2-Classic instances and a load balancer in a VPC with ClassicLink enabled, you can link the EC2-Classic instances to that VPC and then register the linked EC2-Classic instances with the load balancer in the VPC.

Note that RegisterInstanceWithLoadBalancer completes when the request has been registered. Instance registration takes a little time to complete. To check the state of the registered instances, use DescribeLoadBalancers or DescribeInstanceHealth.

After the instance is registered, it starts receiving traffic and requests from the load balancer. Any instance that is not in one of the Availability Zones registered for the load balancer is moved to the OutOfService state. If an Availability Zone is added to the load balancer later, any instances registered with the load balancer move to the InService state.

To deregister instances from a load balancer, use DeregisterInstancesFromLoadBalancer.

For more information, see Register or De-Register EC2 Instances in the Classic Load Balancers Guide.

Parameters:

  • load_balancer_name (AccessPointName) –

    The name of the load balancer.

  • instances (Instances) –

    The IDs of the instances.

Raises:

Examples:

To register instances with a load balancer This example registers the specified instance with the specified load balancer.

>>> await client.register_instances_with_load_balancer(load_balancer_name='my-load-balancer', instances=[{'InstanceId': 'i-d6f6fae3'}])
Source code in docs_src/capo_elastic_load_balancing/_services/async_elastic_load_balancing.py
async def register_instances_with_load_balancer(
    self,
    load_balancer_name: "capo_elastic_load_balancing.types.access_point_name.AccessPointName",
    instances: "capo_elastic_load_balancing.types.instances.Instances",
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.register_end_points_output.RegisterEndPointsOutput":
    """<p>Adds the specified instances to the specified load balancer.</p> <p>The instance must be a running instance in the same network as the load balancer (EC2-Classic or the same VPC). If you have EC2-Classic instances and a load balancer in a VPC with ClassicLink enabled, you can link the EC2-Classic instances to that VPC and then register the linked EC2-Classic instances with the load balancer in the VPC.</p> <p>Note that <code>RegisterInstanceWithLoadBalancer</code> completes when the request has been registered. Instance registration takes a little time to complete. To check the state of the registered instances, use <a>DescribeLoadBalancers</a> or <a>DescribeInstanceHealth</a>.</p> <p>After the instance is registered, it starts receiving traffic and requests from the load balancer. Any instance that is not in one of the Availability Zones registered for the load balancer is moved to the <code>OutOfService</code> state. If an Availability Zone is added to the load balancer later, any instances registered with the load balancer move to the <code>InService</code> state.</p> <p>To deregister instances from a load balancer, use <a>DeregisterInstancesFromLoadBalancer</a>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-deregister-register-instances.html">Register or De-Register EC2 Instances</a> in the <i>Classic Load Balancers Guide</i>.</p>

    Args:
        load_balancer_name: <p>The name of the load balancer.</p>
        instances: <p>The IDs of the instances.</p>

    Raises:
        capo_elastic_load_balancing.errors.access_point_not_found_exception.AccessPointNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing.errors.invalid_end_point_exception.InvalidEndPointException: <p>The specified endpoint is not valid.</p>
        capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To register instances with a load balancer
        This example registers the specified instance with the specified load balancer.

        >>> await client.register_instances_with_load_balancer(load_balancer_name='my-load-balancer', instances=[{'InstanceId': 'i-d6f6fae3'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elastic_load_balancing.types.register_end_points_input.RegisterEndPointsInput]",
    ) -> AsyncOperationResponse[
        "capo_elastic_load_balancing.types.register_end_points_output.RegisterEndPointsOutput"
    ]:
        import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.register_instances_with_load_balancer

        (
            output,
            http_response,
        ) = await capo_elastic_load_balancing._operations.elastic_load_balancing_v7.register_instances_with_load_balancer.async_register_instances_with_load_balancer(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RegisterInstancesWithLoadBalancer")
    )
    input_: capo_elastic_load_balancing.types.register_end_points_input.RegisterEndPointsInput = {
        "load_balancer_name": load_balancer_name,
        "instances": instances,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output