Skip to content

detach_traffic_sources async

detach_traffic_sources(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    traffic_sources: Optional[TrafficSources] = None,
) -> DetachTrafficSourcesResultType

Detaches one or more traffic sources from the specified Auto Scaling group.

When you detach a traffic source, it enters the Removing state while deregistering the instances in the group. When all instances are deregistered, then you can no longer describe the traffic source using the DescribeTrafficSources API call. The instances continue to run.

Parameters:

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

    The name of the Auto Scaling group.

  • traffic_sources (Optional[TrafficSources], default: None ) –

    The unique identifiers of one or more traffic sources. You can specify up to 10 traffic sources.

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_traffic_sources(auto_scaling_group_name='my-auto-scaling-group', traffic_sources=[{'Identifier': '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_traffic_sources(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    traffic_sources: Optional[
        "capo_auto_scaling.types.traffic_sources.TrafficSources"
    ] = None,
) -> "capo_auto_scaling.types.detach_traffic_sources_result_type.DetachTrafficSourcesResultType":
    """<p>Detaches one or more traffic sources from the specified Auto Scaling group.</p> <p>When you detach a traffic source, 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 traffic source using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeTrafficSources.html">DescribeTrafficSources</a> API call. The instances continue to run.</p>

    Args:
        auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
        traffic_sources: <p>The unique identifiers of one or more traffic sources. You can specify up to 10 traffic sources.</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_traffic_sources(auto_scaling_group_name='my-auto-scaling-group', traffic_sources=[{'Identifier': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.detach_traffic_sources_type.DetachTrafficSourcesType]",
    ) -> AsyncOperationResponse[
        "capo_auto_scaling.types.detach_traffic_sources_result_type.DetachTrafficSourcesResultType"
    ]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.detach_traffic_sources

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DetachTrafficSources")
    )
    input_: capo_auto_scaling.types.detach_traffic_sources_type.DetachTrafficSourcesType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if traffic_sources is not None:
        input_["traffic_sources"] = traffic_sources

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