'Domain name cannot be used in Cloudfront after deletion of distribution

I have created a cloudfront distribution and have set the alternate domain name to www.example.com, with an associated certificate. I have then deleted the distribution, without removing the alternate domain from the distribution first, and tried to create another distribution with www.example.com as the alternate domain name again. This time it fails and says:

One or more aliases specified for the distribution includes an incorrectly configured DNS record that points to another CloudFront distribution. You must update the DNS record to correct the problem.

This does not happen if I remove the alternate domain name from the distribution before deleting it.

Is there anyway to clear this error so that I can set www.example.com as the alternate domain name for a new distribution?

Edit: The domain name is managed through Google Domains



Solution 1:[1]

I had a similar case, the only difference being that the domain name was managed through Route 53 and AWS Certificate Manager, not Google Domains.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-move suggests checking via AWS CLI for the conflicting aliases, however, the result of the command was that there are no conflicting aliases:

$ aws cloudfront list-conflicting-aliases --alias *** --distribution-id ***
{
    "ConflictingAliasesList": {
        "MaxItems": 100,
        "Quantity": 0,
        "Items": []
    }
}

So this was a dead-end.

The actual solution for me was… to wait: the next day, after around 16 hours, out of nowhere I was able to add the alternate domain successfully.

My guess is that we see that the old distribution is removed, while what we don't see, some leftovers (like the alternate domain association to the old distribution) are still pending for deletion.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Toreno96