Skip to content

detach_load_balancer_from_subnets

detach_load_balancer_from_subnets(
    load_balancer_name: AccessPointName,
    subnets: Subnets,
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> DetachLoadBalancerFromSubnetsOutput

Removes the specified subnets from the set of configured subnets for the load balancer.

After a subnet is removed, all EC2 instances registered with the load balancer in the removed subnet go into the OutOfService state. Then, the load balancer balances the traffic among the remaining routable subnets.

Parameters:

  • load_balancer_name (AccessPointName) –

    The name of the load balancer.

  • subnets (Subnets) –

    The IDs of the subnets.

Raises:

Examples:

To detach a load balancer from a subnet This example detaches the specified load balancer from the specified subnet.

>>> client.detach_load_balancer_from_subnets(load_balancer_name='my-load-balancer', subnets=['subnet-0ecac448'])
Source code in docs_src/capo_elastic_load_balancing/_services/elastic_load_balancing.py
def detach_load_balancer_from_subnets(
    self,
    load_balancer_name: "capo_elastic_load_balancing.types.access_point_name.AccessPointName",
    subnets: "capo_elastic_load_balancing.types.subnets.Subnets",
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.detach_load_balancer_from_subnets_output.DetachLoadBalancerFromSubnetsOutput":
    """<p>Removes the specified subnets from the set of configured subnets for the load balancer.</p> <p>After a subnet is removed, all EC2 instances registered with the load balancer in the removed subnet go into the <code>OutOfService</code> state. Then, the load balancer balances the traffic among the remaining routable subnets.</p>

    Args:
        load_balancer_name: <p>The name of the load balancer.</p>
        subnets: <p>The IDs of the subnets.</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_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration change is not valid.</p>
        capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To detach a load balancer from a subnet
        This example detaches the specified load balancer from the specified subnet.

        >>> client.detach_load_balancer_from_subnets(load_balancer_name='my-load-balancer', subnets=['subnet-0ecac448'])
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing.types.detach_load_balancer_from_subnets_input.DetachLoadBalancerFromSubnetsInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing.types.detach_load_balancer_from_subnets_output.DetachLoadBalancerFromSubnetsOutput"
    ]:
        import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.detach_load_balancer_from_subnets

        output, http_response = (
            capo_elastic_load_balancing._operations.elastic_load_balancing_v7.detach_load_balancer_from_subnets.detach_load_balancer_from_subnets(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DetachLoadBalancerFromSubnets")
    )
    input_: capo_elastic_load_balancing.types.detach_load_balancer_from_subnets_input.DetachLoadBalancerFromSubnetsInput = {
        "load_balancer_name": load_balancer_name,
        "subnets": subnets,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output