Choose how to move the alternate domain name
Depending on your situation, choose from the following ways to move the alternate domain name:
- The target is a distribution tenant
-
When you create or update the target distribution tenant, set
OnDomainTakeovertoallow. This works whether the source is in the same AWS account or a different one, and the source doesn't need to be disabled. For more information, see Move domains when you create or update a distribution tenant.To move a domain that's serving traffic, use update-domain-association instead, which checks that a certificate covers the domain. For more information, see Migrate a live domain without downtime.
- The source and target distributions (standard or tenant) are in the same AWS account
-
Use the update-domain-association command in the AWS Command Line Interface (AWS CLI) to move the alternate domain name.
This command works for all same-account moves, including when the alternate domain name is an apex domain (also called a root domain, like example.com). For same-account moves, it doesn't require a DNS record that points to the target.
- The source and target distributions (standard or tenant) are in different AWS accounts
-
Use the update-domain-association command. The source standard distribution or distribution tenant can be enabled, so viewers keep reaching the domain during the move. A DNS record must prove that you control the alternate domain name, as described in Set up the target standard distribution or distribution tenant. This works for apex domains too.
You can also use a wildcard to move the alternate domain name. For more information, see Use a wildcard to move an alternate domain name. For additional help, see Contact AWS Support to move an alternate domain name.
We recommend that you use update-domain-association. You can use the associate-alias command, but this command only supports standard distributions. See AssociateAlias in the Amazon CloudFront API Reference.
Migrate a live domain without downtime
To move a domain that's serving traffic, use update-domain-association. It moves the domain only if a certificate on the target covers it, so HTTPS keeps working through the move. Prove that you control the domain before the move, and point the domain to the target only after the move. Viewers keep using the source's DNS name until the domain has moved, and CloudFront keeps serving the domain throughout. Because the domain still points to the source, you can also roll back without changing the DNS record that viewers use.
This procedure applies when viewers reach the domain through the shared CloudFront IP addresses. If the source or the target uses Anycast static IPs, a live migration doesn't work the same way. Requests that still arrive on the source's Anycast static IP addresses after the move might fail until viewers pick up the DNS change, so lower the TTL first and update the domain's DNS record as soon as the move completes.
To migrate a live domain
-
Lower the TTL of the domain's DNS record, so that viewers pick up the DNS change in step 6 quickly.
-
Make sure that a certificate on the target covers the domain. For a distribution tenant, this can be the distribution tenant's certificate or its multi-tenant distribution's certificate. If no certificate covers the domain, update-domain-association doesn't move it.
-
If the source and the target are in different AWS accounts, create a TXT record that associates the domain with the target. Leave the DNS record that viewers use, such as a CNAME or alias record, pointing to the source. The DNS check passes on a record that points to the resource that you move the domain to, and a record that points to a different CloudFront resource doesn't block the move. So the TXT record lets you move the domain to the target, and a CNAME record that viewers use lets you move it back to the source, without a DNS change in between.
If the source and the target are in the same AWS account, skip this step. update-domain-association doesn't check DNS for moves within one AWS account, in either direction.
The name of the TXT record depends on the type of domain. The value is the CloudFront domain name of the target standard distribution, or the routing endpoint of the target distribution tenant's connection group, such as d111111abcdef8.cloudfront.net.
Domain type Domain TXT record Subdomain www.example.com_www.example.com TXT d111111abcdef8.cloudfront.netApex (root) domain example.com_.example.com TXT d111111abcdef8.cloudfront.netWildcard domain *.example.com_*.example.com TXT d111111abcdef8.cloudfront.net -
Using credentials for the AWS account that owns the target, get the target's current ETag, and then move the domain. Replace the IDs, the ETag, and the domain with your own.
aws cloudfront get-distribution-tenant --iddt_9Fd3xTZq7Hl2KABCaws cloudfront update-domain-association \ --domain "www.example.com" \ --target-resource DistributionTenantId=dt_9Fd3xTZq7Hl2KABC\ --if-matchE3UN6WX5ABC123If the target is a standard distribution, use get-distribution and specify
DistributionId=forEDFDVBD6EXAMPLE--target-resource. When the change reaches the edge locations, CloudFront routes requests for the domain to the target, including requests that still arrive through the source's DNS name. -
After the target is deployed, check that it serves the domain as expected. If it doesn't, move the domain back by running update-domain-association again with the source as the target resource, using credentials for the source's AWS account. You don't need to change DNS first. For a move between AWS accounts, both records from step 3 are already in place, so the move back passes on the CNAME record that viewers use, which points to the source, and the TXT record that points to the target doesn't block it. If you already pointed the domain to the target in step 6, point it back to the source first.
If viewers reach the domain through an alias record, as is common for an apex domain, the alias record doesn't pass the DNS check, so the TXT record is the only proof that you control the domain. Before you move the domain back to a source in a different AWS account, update the TXT record from step 3 to associate the domain with the source.
-
In your DNS configuration, point the domain to the target. For a distribution tenant, use the routing endpoint of its connection group. For more information, see Point domains to CloudFront. If you need to roll back after this step, first point the domain back to the source, and then move the domain back as described in step 5.
-
After the old DNS TTL has passed and you no longer need to roll back, you can delete the TXT record, if you created one, and the source's configuration for the domain.
The target's cache starts empty, so your origin receives more requests right after the move. To limit the impact, move a few domains at a time.
Move domains when you create or update a distribution tenant
When you create or update a distribution tenant, you can move domains that are already
associated with another standard distribution or distribution tenant to the distribution tenant in the same request. To do
this, set OnDomainTakeover in the CreateDistributionTenant or UpdateDistributionTenant request. Valid values are:
-
reject(default) – If a domain in the request is already associated with another standard distribution or distribution tenant, the request fails withCNAMEAlreadyExists. -
allow– CloudFront moves each domain in the request that's already associated with another standard distribution or distribution tenant to this distribution tenant.
Unlike update-domain-association, which moves one domain at a time to an existing resource, this moves up to 5 domains as part of creating or updating the distribution tenant.
CloudFront removes the domains from their sources and creates or updates the distribution tenant in one operation. If CloudFront can't move one of the domains, the request fails and no domains move.
For each domain that CloudFront moves, the following must be true:
-
A DNS record proves that you control the domain and points the domain to this distribution tenant. Usually, this is the domain's CNAME record. Use one of the following records:
-
A CNAME record that points the domain to the routing endpoint of the distribution tenant's connection group.
-
An A record that resolves the domain to the Anycast static IP addresses of the distribution tenant's connection group.
-
A TXT record that associates the domain with the routing endpoint of the distribution tenant's connection group.
The name of the TXT record depends on the type of domain. The value is the CloudFront domain name of the target standard distribution, or the routing endpoint of the target distribution tenant's connection group, such as d111111abcdef8.cloudfront.net.
Domain type Domain TXT record Subdomain www.example.com_www.example.com TXT d111111abcdef8.cloudfront.netApex (root) domain example.com_.example.com TXT d111111abcdef8.cloudfront.netWildcard domain *.example.com_*.example.com TXT d111111abcdef8.cloudfront.net
An apex domain, such as
example.com, can't have a CNAME record, and an alias record that resolves the domain to the shared CloudFront IP addresses doesn't prove that you control the domain. For an apex domain, use a TXT record, or an A record that resolves to the Anycast static IP addresses of the connection group.CloudFront checks DNS for every domain that it moves, including when the source and the distribution tenant are in the same AWS account.
-
-
The source isn't owned by an AWS account that CloudFront blocks from moving domains, or by another AWS service.
-
If the source is in a different AWS account, that AWS account doesn't also serve the domain with
anycast-ip-list-only. Otherwise, the request fails withInvalidAssociation. For more information, see Serve domains on specific IP addresses with address-based selection.
A move can remove the last domain from the source standard distribution or distribution tenant.
A certificate isn't required to move a domain. If a certificate on the distribution tenant or its multi-tenant distribution covers the domain, CloudFront serves the domain over HTTPS as soon as it moves. If no certificate covers the domain, CloudFront still moves it and serves it over HTTP only, so HTTPS requests for the domain fail until you add a certificate. For more information, see Serve distribution tenant domains without a certificate.
If you request a CloudFront managed certificate for a domain that you're moving, CloudFront moves the domain when you make the request, and HTTPS requests for the domain fail until the certificate is issued. If you request the managed certificate with self-hosted validation and CloudFront can't verify the DNS record for a domain, the request fails and no domains move.
CloudFront doesn't keep a record of where a moved domain came from. If you later remove the domain from the distribution tenant, delete the distribution tenant, or roll back the change, for example in a CloudFormation stack rollback, CloudFront doesn't return the domain to the source. CloudFront stops serving the domain until you add it to a resource again.
To undo a move, move the domain back to the original resource instead of removing it from the distribution tenant. For more information, see Move a domain back to its original resource.
To move domains when you update a distribution tenant
-
If the source serves a domain over HTTPS, add a certificate that covers the domain to the distribution tenant or its multi-tenant distribution.
WarningIf no certificate covers the domain, HTTPS requests for the domain start failing when it moves. To have CloudFront check this for you, move the domain with update-domain-association instead. For more information, see Migrate a live domain without downtime.
-
Set up the DNS record for each domain that you're moving, as described earlier in this topic. For example, create a CNAME record that points
www.example.comto the routing endpoint of the target distribution tenant's connection group. For an apex domain, create a TXT record, or an A record that resolves the domain to the Anycast static IP addresses of the connection group.NoteUntil the move completes, the source continues to serve the domain.
-
Update the distribution tenant with the full list of its domains, including the domains that you're moving, and set
--on-domain-takeovertoallow.aws cloudfront update-distribution-tenant \ --iddt_9Fd3xTZq7Hl2KABC\ --if-matchE3UN6WX5ABC123\ --domains '[{"Domain": "app.example.com"}, {"Domain": "www.example.com"}]' \ --on-domain-takeover allowIf the request succeeds, the response lists the moved domains in
Domains. CloudFront doesn't returnOnDomainTakeoverin the response, and you must set it again in each request that moves domains.
To move domains while you create a distribution tenant, add --on-domain-takeover
allow to the create-distribution-tenant
command.
Move a domain back to its original resource
To undo a move, move the domain from the distribution tenant back to the original standard distribution or distribution tenant instead of removing it from the distribution tenant. Choose one of the following options.
If you already removed the domain from the distribution tenant, no resource has the domain. Add it to the original resource again as an alternate domain name, and point the domain's DNS records back to that resource.
Use a wildcard to move an alternate domain name
If the source distribution is in a different AWS account than the target distribution, you can also use a wildcard to move the alternate domain name, instead of update-domain-association.
You can't use a wildcard to move an apex domain (like example.com). To move an apex domain, use update-domain-association.
To use a wildcard to move an alternate domain name
This process involves multiple updates to your distributions. Wait for each distribution to fully deploy the latest change before proceeding to the next step.
-
Update the target distribution to add a wildcard alternate domain name that covers the alternate domain name that you are moving. For example, if the alternate domain name that you’re moving is www.example.com, add the alternate domain name *.example.com to the target distribution. To do this, the SSL/TLS certificate on the target distribution must include the wildcard domain name. For more information, see Update a distribution.
-
Update the DNS settings for the alternate domain name to point to the domain name of the target distribution. For example, if the alternate domain name that you’re moving is www.example.com, update the DNS record for www.example.com to route traffic to the domain name of the target distribution (for example d111111abcdef8.cloudfront.net).
NoteEven after you update the DNS settings, the alternate domain name is still served by the source distribution because that’s where the alternate domain name is currently configured.
-
Update the source distribution to remove the alternate domain name. For more information, see Update a distribution.
-
Update the target distribution to add the alternate domain name. For more information, see Update a distribution.
-
Use dig (or a similar DNS query tool) to validate that the DNS record for the alternate domain name resolves to the domain name of the target distribution.
-
(Optional) Update the target distribution to remove the wildcard alternate domain name.
Contact AWS Support to move an alternate domain name
If the source and target distributions are in different AWS accounts, and you can't move the alternate domain name yourself, you can contact Support to move it.
To contact Support to move an alternate domain name
-
Set up a target distribution, including the DNS TXT record that points to the target distribution. For more information, see Set up the target standard distribution or distribution tenant.
-
Contact Support
to request that they verify that you own the domain, and move the domain to the new CloudFront distribution for you. -
After the target distribution is fully deployed, update your DNS configuration to point the alternate domain name’s DNS record to the distribution domain name of the target distribution.