detach_load_balancers

AutoScaling.Client.detach_load_balancers(**kwargs)

Detaches one or more Classic Load Balancers from the specified Auto Scaling group.

This operation detaches only Classic Load Balancers. If you have Application Load Balancers, Network Load Balancers, or Gateway Load Balancer, use the DetachLoadBalancerTargetGroups API instead.

When you detach a load balancer, it enters the Removing state while deregistering the instances in the group. When all instances are deregistered, then you can no longer describe the load balancer using the DescribeLoadBalancers API call. The instances remain running.

See also: AWS API Documentation

Request Syntax

response = client.detach_load_balancers(
    AutoScalingGroupName='string',
    LoadBalancerNames=[
        'string',
    ]
)
Parameters
  • AutoScalingGroupName (string) --

    [REQUIRED]

    The name of the Auto Scaling group.

  • LoadBalancerNames (list) --

    [REQUIRED]

    The names of the load balancers. You can specify up to 10 load balancers.

    • (string) --
Return type

dict

Returns

Response Syntax

{}

Response Structure

  • (dict) --

Exceptions

  • AutoScaling.Client.exceptions.ResourceContentionFault

Examples

This example detaches the specified load balancer from the specified Auto Scaling group.

response = client.detach_load_balancers(
    AutoScalingGroupName='my-auto-scaling-group',
    LoadBalancerNames=[
        'my-load-balancer',
    ],
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}