- Newest
- Most votes
- Most comments
This behavior is actually the intended functionality of CloudFront when dealing with overlapping alternate domain names (CNAMEs).
When you have two CloudFront distributions with the same alternate domain name configured (in your case, "some.test.domain" was configured on both A CloudFront and B CloudFront), CloudFront's behavior is not determined by your DNS settings in Route 53. Instead, CloudFront has its own internal routing logic.
CloudFront identifies which distribution should handle a request based on the "Host" header in the HTTP request. When a request comes in for "some.test.domain", CloudFront looks at all distributions that have this domain configured as an alternate domain name.
In cases where there's an overlap between a specific domain name and a wildcard domain name (like "some.test.domain" and ".test.domain"), CloudFront will prioritize the more specific match. In your scenario, "some.test.domain" is more specific than ".test.domain", so B CloudFront (which had the exact domain configured) was handling the requests instead of A CloudFront (which had the wildcard).
This is why removing "some.test.domain" from B CloudFront resolved the issue - it eliminated the duplicate configuration, allowing the wildcard configuration on A CloudFront to take effect.
It's important to note that CloudFront has restrictions against duplicate alternate domain names across distributions, even if they're owned by the same AWS account. Each alternate domain name must be unique across all CloudFront distributions globally, with the exception of wildcard domains that can overlap with more specific domains (as in your case).
Sources
Use custom URLs by adding alternate domain names (CNAMEs) - Amazon CloudFront
I remove my cloudfront deployment and create it again. But, When i create new deployment and use my prev domain, it can't access and error is occured. | AWS re:Post
