Skip to content

delete_load_balancer async

delete_load_balancer(
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = None,
    load_balancer_arn: Optional[LoadBalancerArn] = None,
) -> DeleteLoadBalancerOutput

Deletes the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer. Deleting a load balancer also deletes its listeners.

You can't delete a load balancer if deletion protection is enabled. If the load balancer does not exist or has already been deleted, the call succeeds.

Deleting a load balancer does not affect its registered targets. For example, your EC2 instances continue to run and are still registered to their target groups. If you no longer need these EC2 instances, you can stop or terminate them.

Parameters:

  • load_balancer_arn (Optional[LoadBalancerArn], default: None ) –

    The Amazon Resource Name (ARN) of the load balancer.

Raises:

Examples:

To delete a load balancer This example deletes the specified load balancer.

>>> await client.delete_load_balancer(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188')
Source code in docs_src/capo_elastic_load_balancing_v2/_services/async_elastic_load_balancingv2.py
async def delete_load_balancer(
    self,
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = None,
    load_balancer_arn: Optional[
        "capo_elastic_load_balancing_v2.types.load_balancer_arn.LoadBalancerArn"
    ] = None,
) -> "capo_elastic_load_balancing_v2.types.delete_load_balancer_output.DeleteLoadBalancerOutput":
    """<p>Deletes the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer. Deleting a load balancer also deletes its listeners.</p> <p>You can't delete a load balancer if deletion protection is enabled. If the load balancer does not exist or has already been deleted, the call succeeds.</p> <p>Deleting a load balancer does not affect its registered targets. For example, your EC2 instances continue to run and are still registered to their target groups. If you no longer need these EC2 instances, you can stop or terminate them.</p>

    Args:
        load_balancer_arn: <p>The Amazon Resource Name (ARN) of the load balancer.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.load_balancer_not_found_exception.LoadBalancerNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing_v2.errors.operation_not_permitted_exception.OperationNotPermittedException: <p>This operation is not allowed.</p>
        capo_elastic_load_balancing_v2.errors.resource_in_use_exception.ResourceInUseException: <p>A specified resource is in use.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete a load balancer
        This example deletes the specified load balancer.

        >>> await client.delete_load_balancer(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elastic_load_balancing_v2.types.delete_load_balancer_input.DeleteLoadBalancerInput]",
    ) -> AsyncOperationResponse[
        "capo_elastic_load_balancing_v2.types.delete_load_balancer_output.DeleteLoadBalancerOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.delete_load_balancer

        (
            output,
            http_response,
        ) = await capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.delete_load_balancer.async_delete_load_balancer(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteLoadBalancer")
    )
    input_: capo_elastic_load_balancing_v2.types.delete_load_balancer_input.DeleteLoadBalancerInput = {}
    if load_balancer_arn is not None:
        input_["load_balancer_arn"] = load_balancer_arn

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