Skip to content

attach_traffic_sources async

attach_traffic_sources(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    traffic_sources: Optional[TrafficSources] = None,
    skip_zonal_shift_validation: Optional[SkipZonalShiftValidation] = None,
) -> AttachTrafficSourcesResultType

Attaches one or more traffic sources to the specified Auto Scaling group.

You can use any of the following as traffic sources for an Auto Scaling group:

  • Application Load Balancer

  • Classic Load Balancer

  • Gateway Load Balancer

  • Network Load Balancer

  • VPC Lattice

This operation is additive and does not detach existing traffic sources from the Auto Scaling group.

After the operation completes, use the DescribeTrafficSources API to return details about the state of the attachments between traffic sources and your Auto Scaling group. To detach a traffic source from the Auto Scaling group, call the DetachTrafficSources API.

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.

  • skip_zonal_shift_validation (Optional[SkipZonalShiftValidation], default: None ) –

    If you enable zonal shift with cross-zone disabled load balancers, capacity could become imbalanced across Availability Zones. To skip the validation, specify true. For more information, see Auto Scaling group zonal shift in the Amazon EC2 Auto Scaling User Guide.

Raises:

Examples:

To attach a target group to an Auto Scaling group This example attaches the specified target group to the specified Auto Scaling group.

>>> await client.attach_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 attach_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,
    skip_zonal_shift_validation: Optional[
        "capo_auto_scaling.types.skip_zonal_shift_validation.SkipZonalShiftValidation"
    ] = None,
) -> "capo_auto_scaling.types.attach_traffic_sources_result_type.AttachTrafficSourcesResultType":
    """<p>Attaches one or more traffic sources to the specified Auto Scaling group.</p> <p>You can use any of the following as traffic sources for an Auto Scaling group:</p> <ul> <li> <p>Application Load Balancer</p> </li> <li> <p>Classic Load Balancer</p> </li> <li> <p>Gateway Load Balancer</p> </li> <li> <p>Network Load Balancer</p> </li> <li> <p>VPC Lattice</p> </li> </ul> <p>This operation is additive and does not detach existing traffic sources from the Auto Scaling group. </p> <p>After the operation completes, use the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeTrafficSources.html">DescribeTrafficSources</a> API to return details about the state of the attachments between traffic sources and your Auto Scaling group. To detach a traffic source from the Auto Scaling group, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachTrafficSources.html">DetachTrafficSources</a> API.</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>
        skip_zonal_shift_validation: <p> If you enable zonal shift with cross-zone disabled load balancers, capacity could become imbalanced across Availability Zones. To skip the validation, specify <code>true</code>. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-zonal-shift.html">Auto Scaling group zonal shift</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>. </p>

    Raises:
        capo_auto_scaling.errors.instance_refresh_in_progress_fault.InstanceRefreshInProgressFault: <p>The request failed because an active instance refresh already exists for the specified Auto Scaling group.</p>
        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.service_linked_role_failure.ServiceLinkedRoleFailure: <p>The service-linked role is not yet ready for use.</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To attach a target group to an Auto Scaling group
        This example attaches the specified target group to the specified Auto Scaling group.

        >>> await client.attach_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.attach_traffic_sources_type.AttachTrafficSourcesType]",
    ) -> AsyncOperationResponse[
        "capo_auto_scaling.types.attach_traffic_sources_result_type.AttachTrafficSourcesResultType"
    ]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.attach_traffic_sources

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AttachTrafficSources")
    )
    input_: capo_auto_scaling.types.attach_traffic_sources_type.AttachTrafficSourcesType = {}
    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
    if skip_zonal_shift_validation is not None:
        input_["skip_zonal_shift_validation"] = skip_zonal_shift_validation

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