
I Tried Moving a Domain to a Multi-Tenant Distribution Using CloudFront SaaS Manager's OnDomainTakeover
This page has been translated by machine translation. View original
Introduction
On November 19, 2026, an update to Amazon CloudFront SaaS Manager (multi-tenant distributions) was announced. You can now move a domain that is in use by another distribution to a tenant with a single request. You can also add a domain before issuing a certificate.
When you specify OnDomainTakeover while creating or updating a tenant, CloudFront verifies domain ownership using DNS records and then moves the domain that is in use.
In this article, I try migrating domains that are in use.
Test environment
- AWS CLI: 2.42.4
- ACM region: N. Virginia (us-east-1)
- Domains to move: dm1.example.com, dm2.example.com, dm3.example.com (referred to as dm1 to dm3 in the text)
- Account: the source and destination are in the same AWS account
- Source: standard distribution
- Destination: multi-tenant distribution
- Connection group: default
- Client: curl from one machine, at about 1-second intervals
- Edge location confirmed with
x-amz-cf-popincurl -i: NRT20-P8 (dm1)
Preparation
Source and destination
The source is a standard distribution that has dm1 to dm3 as alternate domain names. The destination is a multi-tenant distribution whose connection mode is tenant-only, with a *.example.com certificate issued in ACM in us-east-1. In both, a CloudFront Functions function associated with viewer-request returns the response. The value of the x-served-by header is source for the source and target for the destination.
Destination definition (multitenant-distribution.json and function)
The code of the function yattemita-dm-target is as follows. The function for the source is the same except that the value of x-served-by and the body are changed to source. Create and publish the functions first.
function handler(event) {
return {
statusCode: 200,
statusDescription: 'OK',
headers: {
'x-served-by': { value: 'target' },
'content-type': { value: 'text/plain' },
'cache-control': { value: 'no-store' }
},
body: 'target\n'
};
}
Save the following configuration as multitenant-distribution.json.
{
"CallerReference": "yattemita-dm-mt-20261129",
"Origins": {"Quantity": 1, "Items": [{
"Id": "dummy",
"DomainName": "example.com",
"CustomOriginConfig": {"HTTPPort": 80, "HTTPSPort": 443, "OriginProtocolPolicy": "https-only"}
}]},
"DefaultCacheBehavior": {
"TargetOriginId": "dummy",
"ViewerProtocolPolicy": "allow-all",
"AllowedMethods": {"Quantity": 2, "Items": ["GET", "HEAD"]},
"CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
"FunctionAssociations": {"Quantity": 1, "Items": [{
"EventType": "viewer-request",
"FunctionARN": "arn:aws:cloudfront::123456789012:function/yattemita-dm-target"
}]}
},
"Comment": "yattemita-dm-target-mt (verification, delete after)",
"Enabled": true,
"ViewerCertificate": {
"ACMCertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/<ID>",
"SSLSupportMethod": "sni-only",
"MinimumProtocolVersion": "TLSv1.2_2021"
},
"TenantConfig": {},
"ConnectionMode": "tenant-only"
}
aws cloudfront create-distribution --distribution-config file://multitenant-distribution.json
DNS records
For each domain to be moved, you need a DNS record (one of CNAME, A, or TXT) that points to the destination tenant. This record is verified even for a migration within the same AWS account.
For a subdomain, the name of the TXT record is the domain name prefixed with _ (example: _dm1.example.com). The value is the routing endpoint of the connection group to which the destination tenant belongs.
I obtained the routing endpoint from the list of connection groups.
aws cloudfront list-connection-groups --query 'ConnectionGroups[].{Id:Id,Name:Name,IsDefault:IsDefault,RoutingEndpoint:RoutingEndpoint}' --output json
The Id and Name lines are omitted from the output.
[
{
"IsDefault": true,
"RoutingEndpoint": "d111111abcdef8.cloudfront.net"
}
]
In this test, I left the CNAMEs of dm1 to dm3 pointing to the source and used TXT records for ownership verification. The records are as follows.
| Name | Type | TTL | Value |
|---|---|---|---|
| dm1.example.com | CNAME | 60 | d222222abcdef8.cloudfront.net |
| dm2.example.com | CNAME | 60 | d222222abcdef8.cloudfront.net |
| dm3.example.com | CNAME | 60 | d222222abcdef8.cloudfront.net |
| _dm1.example.com | TXT | 60 | "d111111abcdef8.cloudfront.net" |
| _dm2.example.com | TXT | 60 | "d111111abcdef8.cloudfront.net" |
| _dm3.example.com | TXT | 60 | "d111111abcdef8.cloudfront.net" |
Measuring responses
I distinguish the responder by the value of the x-served-by header. For measurement, I used a script that repeats curl at about 1-second intervals and writes the time, status code, x-served-by value, and elapsed time (seconds) one line at a time. The command to send HTTPS requests to dm1 is as follows.
bash probe.sh dm1.example.com https probe-dm1.txt 1
probe.sh
#!/usr/bin/env bash
# Usage: probe.sh <hostname> <scheme> <output file> [interval in seconds]
# 1 line = time / status / x-served-by / elapsed seconds. Status on failure is 000
set -u
HOST=$1; SCHEME=$2; OUT=$3; INTERVAL=${4:-1}
while true; do
TS=$(date +%Y-%m-%dT%H:%M:%S%z)
RES=$(curl -s -o /dev/null -D - -m 5 -w 'CODE=%{http_code} TIME=%{time_total}\n' "${SCHEME}://${HOST}/" 2>/dev/null)
CODE=$(sed -n 's/.*CODE=\([0-9]*\).*/\1/p' <<<"$RES")
TIME=$(sed -n 's/.*TIME=\([0-9.]*\).*/\1/p' <<<"$RES")
SERVED=$(grep -i '^x-served-by:' <<<"$RES" | tr -d '\r' | awk '{print $2}')
printf '%s %s served_by=%s time=%s\n' "$TS" "${CODE:-000}" "${SERVED:--}" "${TIME:--}" >> "$OUT"
sleep "$INTERVAL"
done
Migrating domains in use
Migrating one domain (when creating a tenant)
After starting continuous requests to dm1, I created the tenant dm-tenant-1 with --on-domain-takeover allow specified. At this point, dm1 was being served by the source. $MT_ID is the ID of the multi-tenant distribution.
aws cloudfront create-distribution-tenant \
--distribution-id $MT_ID \
--name dm-tenant-1 \
--domains Domain=dm1.example.com \
--on-domain-takeover allow \
--enabled \
--output json
In the response, the Status of dm1 was active and the Status of the tenant was InProgress.
All 47 HTTPS requests sent from one client at about 1-second intervals returned 200. The command was run at 02:13:10, and about 6 seconds later, at 02:13:16, the responder switched from source to target exactly once. The lines before and after the switch are as follows.
2026-11-29T02:13:14+0900 200 served_by=source time=0.029401
2026-11-29T02:13:15+0900 200 served_by=source time=0.040878
2026-11-29T02:13:16+0900 200 served_by=target time=1.464877
2026-11-29T02:13:18+0900 200 served_by=target time=0.178712
2026-11-29T02:13:19+0900 200 served_by=target time=0.117436
Migrating two domains (when updating a tenant)
With a single update-distribution-tenant update, I moved dm2 and dm3 at the same time. In --domains, list all domains, including dm1, which is already in the tenant. $TENANT_ID is the ID of the tenant, and $ETAG is the latest ETag of the tenant.
aws cloudfront update-distribution-tenant \
--id $TENANT_ID \
--if-match $ETAG \
--domains Domain=dm1.example.com Domain=dm2.example.com Domain=dm3.example.com \
--on-domain-takeover allow \
--output json
In the response, the Status of all three domains was active.
After the update, I retrieved the state of the source and the tenant, and confirmed that the source had 0 alternate domain names and that the tenant had the three domains.
Commands to get the state and results
aws cloudfront get-distribution --id $SOURCE_ID --query '{Status:Distribution.Status,Aliases:Distribution.DistributionConfig.Aliases}' --output json
aws cloudfront get-distribution-tenant --id $TENANT_ID --query 'DistributionTenant.{Status:Status,Domains:Domains[].Domain}' --output json
{
"Status": "Deployed",
"Aliases": {
"Quantity": 0
}
}
{
"Status": "Deployed",
"Domains": [
"dm1.example.com",
"dm2.example.com",
"dm3.example.com"
]
}
Adding a domain without a certificate
You can also add a domain without a certificate to a tenant. Until you attach a certificate, the domain is served over HTTP only. The procedure is in the official guide.
Notes
- You can move up to 5 domains per request.
OnDomainTakeoverdoes not check whether the destination certificate covers the domain. Therefore, if it does not, HTTPS requests fail at the same time as the migration. It is recommended to confirm that the certificate covers the domain before moving. For moving without interrupting HTTPS, the official guide points toupdate-domain-association, which performs this check.- CloudFront does not record the source. The domain does not return to the source whether you remove the domain from the tenant, delete the tenant, or roll back the CloudFormation stack.
For details, see the official guide.
Summary
With Amazon CloudFront multi-tenant distributions, you can now move domains in use from a standard distribution. In the test, I confirmed that the domains could be moved without errors.
Previously, you had to temporarily stop the standard distribution or ask AWS Support. Asking AWS Support also had the problem that it was hard to adjust the timing of moving the domain.
If you wanted to use multi-tenant distributions but found a no-downtime migration difficult, you can use this update. When you do, check the "Notes" section.
