Interview Prep/AWS/Route 53, CloudFront, API Gateway and Messaging

Adding an alternate domain name fails: `CNAMEAlreadyExists: One or more of the CNAMEs you provided are already associated with a different resource.`

IntermediateTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer

Likely causes → Another distribution, possibly in another account (an old environment or a vendor), already has that alternate domain name.

Diagnose →

aws cloudfront list-conflicting-aliases --distribution-id E123ABC --alias www.example.com
aws cloudfront list-distributions --query "DistributionList.Items[?contains(Aliases.Items,'www.example.com')].Id"

Fix →

  1. Same account: remove the alias from the old distribution, then add it to the new one
  2. Different account: prove ownership with a TXT record (_www.example.com pointing to the new distribution's domain) and run aws cloudfront associate-alias --target-distribution-id E123ABC --alias www.example.com

Prevent → Track aliases in IaC, and remove them when you decommission distributions.

aws All AWS questions Roadmap: AWS core services

More on Route 53, CloudFront, API Gateway and Messaging