Skip to content

detach_load_balancer_target_groups async

detach_load_balancer_target_groups(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    target_group_ar_ns: Optional[TargetGroupARNs] = None,
) -> DetachLoadBalancerTargetGroupsResultType

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 DetachLoadBalancerTargetGroups. You can use both the original DetachLoadBalancerTargetGroups API operation and DetachTrafficSources on the same Auto Scaling group.

Detaches one or more target groups from the specified Auto Scaling group.

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

You can use this operation to detach target groups that were attached by using AttachLoadBalancerTargetGroups, but not for target groups that were attached by using AttachTrafficSources.

Parameters:

  • auto_scaling_group_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the Auto Scaling group.

  • target_group_ar_ns (Optional[TargetGroupARNs], default: None ) –

    The Amazon Resource Names (ARN) of the target groups. You can specify up to 10 target groups.

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 target group from an Auto Scaling group This example detaches the specified target group from the specified Auto Scaling group

>>> await client.detach_load_balancer_target_groups(auto_scaling_group_name='my-auto-scaling-group', target_group_ar_ns=['arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067'])
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
async def detach_load_balancer_target_groups(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    target_group_ar_ns: Optional[
        "capo_auto_scaling.types.target_group_ar_ns.TargetGroupARNs"
    ] = None,
) -> "capo_auto_scaling.types.detach_load_balancer_target_groups_result_type.DetachLoadBalancerTargetGroupsResultType":
    """<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>DetachLoadBalancerTargetGroups</code>. You can use both the original <code>DetachLoadBalancerTargetGroups</code> API operation and <code>DetachTrafficSources</code> on the same Auto Scaling group.</p> </note> <p>Detaches one or more target groups from the specified Auto Scaling group.</p> <p>When you detach a target group, 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 target group using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeLoadBalancerTargetGroups.html">DescribeLoadBalancerTargetGroups</a> API call. The instances remain running.</p> <note> <p>You can use this operation to detach target groups that were attached by using <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_AttachLoadBalancerTargetGroups.html">AttachLoadBalancerTargetGroups</a>, but not for target groups that were attached by using <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_AttachTrafficSources.html">AttachTrafficSources</a>.</p> </note>

    Args:
        auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
        target_group_ar_ns: <p>The Amazon Resource Names (ARN) of the target groups. You can specify up to 10 target groups.</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 target group from an Auto Scaling group
        This example detaches the specified target group from the specified Auto Scaling group

        >>> await client.detach_load_balancer_target_groups(auto_scaling_group_name='my-auto-scaling-group', target_group_ar_ns=['arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.detach_load_balancer_target_groups_type.DetachLoadBalancerTargetGroupsType]",
    ) -> AsyncOperationResponse[
        "capo_auto_scaling.types.detach_load_balancer_target_groups_result_type.DetachLoadBalancerTargetGroupsResultType"
    ]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.detach_load_balancer_target_groups

        (
            output,
            http_response,
        ) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.detach_load_balancer_target_groups.async_detach_load_balancer_target_groups(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DetachLoadBalancerTargetGroups")
    )
    input_: capo_auto_scaling.types.detach_load_balancer_target_groups_type.DetachLoadBalancerTargetGroupsType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if target_group_ar_ns is not None:
        input_["target_group_ar_ns"] = target_group_ar_ns

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