Skip to content

associate_alias async

associate_alias(
    target_distribution_id: string,
    alias: string,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> None

The AssociateAlias API operation only supports standard distributions. To move domains between distribution tenants and/or standard distributions, we recommend that you use the UpdateDomainAssociation API operation instead.

Associates an alias with a CloudFront standard distribution. An alias is commonly known as a custom domain or vanity domain. It can also be called a CNAME or alternate domain name.

With this operation, you can move an alias that's already used for a standard distribution to a different standard distribution. This prevents the downtime that could occur if you first remove the alias from one standard distribution and then separately add the alias to another standard distribution.

To use this operation, specify the alias and the ID of the target standard distribution.

For more information, including how to set up the target standard distribution, prerequisites that you must complete, and other restrictions, see Moving an alternate domain name to a different standard distribution or distribution tenant in the Amazon CloudFront Developer Guide.

Parameters:

  • target_distribution_id (string) –

    The ID of the standard distribution that you're associating the alias with.

  • alias (string) –

    The alias (also known as a CNAME) to add to the target standard distribution.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def associate_alias(
    self,
    target_distribution_id: "capo_cloudfront.types.string.string",
    alias: "capo_cloudfront.types.string.string",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> None:
    """<note> <p>The <code>AssociateAlias</code> API operation only supports standard distributions. To move domains between distribution tenants and/or standard distributions, we recommend that you use the <a href="https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_UpdateDomainAssociation.html">UpdateDomainAssociation</a> API operation instead.</p> </note> <p>Associates an alias with a CloudFront standard distribution. An alias is commonly known as a custom domain or vanity domain. It can also be called a CNAME or alternate domain name.</p> <p>With this operation, you can move an alias that's already used for a standard distribution to a different standard distribution. This prevents the downtime that could occur if you first remove the alias from one standard distribution and then separately add the alias to another standard distribution.</p> <p>To use this operation, specify the alias and the ID of the target standard distribution.</p> <p>For more information, including how to set up the target standard distribution, prerequisites that you must complete, and other restrictions, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-move">Moving an alternate domain name to a different standard distribution or distribution tenant</a> in the <i>Amazon CloudFront Developer Guide</i>.</p>

    Args:
        target_distribution_id: <p>The ID of the standard distribution that you're associating the alias with.</p>
        alias: <p>The alias (also known as a CNAME) to add to the target standard distribution.</p>

    Raises:
        capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
        capo_cloudfront.errors.illegal_update.IllegalUpdate: <p>The update contains modifications that are not allowed.</p>
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
        capo_cloudfront.errors.no_such_distribution.NoSuchDistribution: <p>The specified distribution does not exist.</p>
        capo_cloudfront.errors.too_many_distribution_cnam_es.TooManyDistributionCNAMEs: <p>Your request contains more CNAMEs than are allowed per distribution.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.associate_alias_request.AssociateAliasRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_cloudfront._operations.cloudfront2020_05_31.associate_alias

        (
            output,
            http_response,
        ) = await capo_cloudfront._operations.cloudfront2020_05_31.associate_alias.async_associate_alias(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateAlias")
    )
    input_: capo_cloudfront.types.associate_alias_request.AssociateAliasRequest = {
        "target_distribution_id": target_distribution_id,
        "alias": alias,
    }

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