title: How Associate Alias working for AWS CloudFront?
body: <p>Let's say that I have two CloudFront distributions:</p>
  <ul>
  <li>id: <code>ABCD1234</code>, domain: <code>abcd1234.cloudfront.net</code> (directed to <code>abcd</code> S3 bucket)</li>
  <li>id: <code>DEFG4321</code>, domain: <code>defg4321.cloudfront.net</code> (directed to <code>defg</code> S3 bucket)</li>
  </ul>
  <p>I set two records in Route53:</p>
  <pre><code>example.domain.com CNAME abcd1234.cloudfront.net
  _example.domain.com TXT defg4321.cloudfront.net
  </code></pre>
  <p>And create associate alias for <code>DEFG4321</code> distribution:</p>
  <pre class="lang-bash prettyprint-override"><code>aws cloudfront associate-alias --target-distribution-id DEFG4321 --alias example.domain.com
  </code></pre>
  <p>When I accessing <code>example.domain.com</code> by browser I can see response from <code>defg</code>. And that is looks okay.</p>
  <p>After that I changing my CNAME record to</p>
  <pre><code>example.domain.com CNAME google.com
  </code></pre>
  <p><code>example.domain.com</code> redirecting me to <code>google.com</code> and I don't able to access <code>defg4321.cloudfront.net</code> anymore...</p>
  <p>So if my understanding is correct looks like browser access flow is:</p>
  <p>request <code>example.domain.com</code> DNS record → get <code>abcd1234.cloudfront.net</code> response → access to <code>abcd1234.cloudfront.net</code> → automatically redirect to <code>defg4321.cloudfront.net</code> by CloudFront internal mechanisms → access to <code>defg4321.cloudfront.net</code> → redirect to <code>defg</code> bucket contents.</p>
  <p>Probably my thoughts is correct but:</p>
  <ol>
  <li>This feature looking pretty weird and non-intuitive</li>
  <li><strong><code>CNAME</code> and <code>TXT</code> records are logically duplicate each other but has different values, is it possible to use only <code>TXT</code> record?</strong></li>
  <li>Is it possible to use any CloudFront distribution as <code>abcd1234.cloudfront.net</code>-like provider to correct distribution? so <code>CNAME</code> may be any random CloudFront distribution?</li>
  <li><strong>IS it possible to set some default (dummy) <code>CNAME</code> entrypoint that will be always redirect me to real <code>TXT</code> record distribution ID?</strong></li>
  </ol>
  <p>PS Yes I understand that it is possible to set same distribution ID to <code>CNAME</code> and <code>TXT</code> records, but I need to periodically switch between distributions and changing both records is double-work, in other way changing of only <code>TXT</code> record may cause problems with understanding what distribution is active in current time (also inactive distribution can't be deleted or disabled without changing both records). Or maybe my understanding of associate alias using is not correct?</p>