This API operation is superseded by DetachTrafficSources, which can detach multiple traffic sources types. We recommend using DetachTrafficSources to simplify how you manage traffic sources. However, we continue to support DetachLoadBalancers. You can use both the original DetachLoadBalancers API operation and DetachTrafficSources on the same Auto Scaling group.
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 Balancers, 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.
Parameters:
Raises:
-
ResourceContentionFault
–
You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To detach a load balancer from an Auto Scaling group
This example detaches the specified load balancer from the specified Auto Scaling group.
>>> await client.detach_load_balancers(auto_scaling_group_name='my-auto-scaling-group', load_balancer_names=['my-load-balancer'])
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
| async def detach_load_balancers(
self,
*,
config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
auto_scaling_group_name: Optional[
"capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
] = None,
load_balancer_names: Optional[
"capo_auto_scaling.types.load_balancer_names.LoadBalancerNames"
] = None,
) -> "capo_auto_scaling.types.detach_load_balancers_result_type.DetachLoadBalancersResultType":
"""<note> <p>This API operation is superseded by <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachTrafficSources.html">DetachTrafficSources</a>, which can detach multiple traffic sources types. We recommend using <code>DetachTrafficSources</code> to simplify how you manage traffic sources. However, we continue to support <code>DetachLoadBalancers</code>. You can use both the original <code>DetachLoadBalancers</code> API operation and <code>DetachTrafficSources</code> on the same Auto Scaling group.</p> </note> <p>Detaches one or more Classic Load Balancers from the specified Auto Scaling group.</p> <p>This operation detaches only Classic Load Balancers. If you have Application Load Balancers, Network Load Balancers, or Gateway Load Balancers, use the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachLoadBalancerTargetGroups.html">DetachLoadBalancerTargetGroups</a> API instead.</p> <p>When you detach a load balancer, it enters the <code>Removing</code> state while deregistering the instances in the group. When all instances are deregistered, then you can no longer describe the load balancer using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeLoadBalancers.html">DescribeLoadBalancers</a> API call. The instances remain running.</p>
Args:
auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
load_balancer_names: <p>The names of the load balancers. You can specify up to 10 load balancers.</p>
Raises:
capo_auto_scaling.errors.resource_contention_fault.ResourceContentionFault: <p>You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).</p>
capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To detach a load balancer from an Auto Scaling group
This example detaches the specified load balancer from the specified Auto Scaling group.
>>> await client.detach_load_balancers(auto_scaling_group_name='my-auto-scaling-group', load_balancer_names=['my-load-balancer'])
"""
async def _handler(
req: "AsyncOperationRequest[capo_auto_scaling.types.detach_load_balancers_type.DetachLoadBalancersType]",
) -> AsyncOperationResponse[
"capo_auto_scaling.types.detach_load_balancers_result_type.DetachLoadBalancersResultType"
]:
import capo_auto_scaling._operations.auto_scaling_2011_01_01.detach_load_balancers
(
output,
http_response,
) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.detach_load_balancers.async_detach_load_balancers(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DetachLoadBalancers")
)
input_: capo_auto_scaling.types.detach_load_balancers_type.DetachLoadBalancersType = {}
if auto_scaling_group_name is not None:
input_["auto_scaling_group_name"] = auto_scaling_group_name
if load_balancer_names is not None:
input_["load_balancer_names"] = load_balancer_names
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|