- Newest
- Most votes
- Most comments
No, you cannot use the same domain name (alternate domain name/CNAME) across multiple CloudFront distributions, even when implementing a failover routing policy in Route 53. Each alternate domain name can only be associated with one CloudFront distribution at a time.
For your failover scenario, you have a few alternative approaches:
-
Use CloudFront Origin Failover: Instead of creating separate distributions, configure origin failover within a single CloudFront distribution. This allows CloudFront to automatically fail over to a secondary origin group if the primary origin fails. You can set up primary and secondary origins with health checks, and CloudFront will handle the failover automatically.
-
Use Different Subdomains: Create separate CloudFront distributions with different alternate domain names (e.g., primary.example.com and secondary.example.com), then use Route 53 failover routing to direct traffic between them. This way, each distribution has its own unique domain name.
-
Implement Failover at the Origin Level: Keep a single CloudFront distribution and implement your failover logic at the origin level, using multiple origins or origin groups within that distribution.
The CloudFront origin failover feature is typically the recommended approach for high availability scenarios, as it's designed specifically for this use case and doesn't require managing multiple distributions or domain names.
No, you cannot assign the same domain name (alternate domain name / CNAME) to more than one CloudFront distribution. This is a CloudFront limitation. As stated in the official Route 53 documentation:
"For failover alias records, you can't specify a CloudFront distribution for both the primary and secondary records. A distribution must include an alternate domain name that matches the name of the record. However, the primary and secondary records have the same name, and you can't include the same alternate domain name in more than one distribution."
In other words, the configuration you're trying to build — pointing the Primary and Secondary records of a Route 53 Failover routing policy to two separate CloudFront distributions that share the same domain name — is not supported.
Alternative Approaches
To achieve high availability, consider one of the following:
1. CloudFront Origin Failover (recommended)
Configure an Origin Group within a single CloudFront distribution, with a primary and a secondary origin. When the primary origin returns a configured error code (e.g., 500, 502, 503, 504), CloudFront automatically retries the request against the secondary origin.
- Pros: Failover is immediate (per-request).
- Caveats: Only GET / HEAD / OPTIONS methods are supported. It is stateless — every request is sent to the primary first and only falls over to the secondary on failure, so latency increases while the primary is down.
2. Route 53 DNS Failover (at the origin level)
Keep a single CloudFront distribution and apply the Route 53 Failover routing policy to the origin's domain name instead. A Route 53 health check monitors the primary origin, and switches to the secondary origin's IP when the primary becomes unhealthy.
- Pros: After failover, all requests go to the secondary origin, so it's stable.
- Caveats: Detection by the health check plus DNS TTL propagation takes time (tens of seconds to a few minutes).
3. Hybrid Approach (most recommended)
Combine options 1 and 2. Use a CloudFront Origin Group for immediate failover while Route 53 DNS Failover switches the origin domain. This way, CloudFront Origin Failover rescues requests during the time Route 53 needs to complete its failover, minimizing downtime.
You can find a detailed walkthrough and a sample CDK implementation in the following AWS blog post: Improve web application availability with CloudFront and Route53 hybrid origin failover
The key takeaway for all of these approaches: use a single CloudFront distribution and implement failover at the origin level.
Relevant content
asked 3 years ago
