The assigned dyyyexample.cloudfront.net
and dzzzexample.cloudfront.net
hostnames that route traffic to your CloudFront distributions go to the same place. CloudFront can't see your DNS alias entries, so it is unaware of which alias was followed.
Instead, it looks at the TLS SNI and the HTTP Host
header the browser sends. It uses this information to match with the Alternate Domain Name for your distribution -- with no change to the DNS.
Your site's hostname, example.com
, is only configured as the Alternate Domain Name on one of your distributions, because CloudFront does not allow you to provision the same value on more than one distribution.
If you swap that Alternate Domain Name entry to the other distribution, all traffic will move go the other distribution.
In short, CloudFront does not directly and natively support Blue/Green or Canary.
The workaround is to use a Lambda@Edge trigger and a cookie to latch each viewer to one origin or another. Lambda@Edge origin request trigger allows the origin to be changed while the request is in flight.
There is an A/B testing example in the docs, but that example swaps out the path. See the Dynamic Origin Selection examples for how to swap out the origin. Combining the logic of these two allows A/B testing across two buckets (or any two alternate back-ends).