Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain name already associated with an "existing" CloudFront distribution

When I try to setup a domain through serverless-domain-manager with sls create_domain, it fails with:

BadRequestException: The domain name you provided is already associated with an existing CloudFront distribution. Remove the domain name from the existing CloudFront distribution or use a different domain name. If you own this domain name and are not using it on an existing CloudFront distribution, please contact support. api.example.com was not created.

I tracked down the line where the library fails.

Note that my account does not have anything in CloudFront. This is what I see when I open it:

enter image description here

It's also interesting that in Certificate Manager, it says that the certificate is in use: enter image description here

Under Associated Resources I can see an entry for cloudfront: arn:aws:cloudfront:: ...

like image 470
Daniel Birowsky Popeski Avatar asked Dec 02 '22 11:12

Daniel Birowsky Popeski


2 Answers

Thanx to Matt's guidance I found what caused the phantom CloudFront distros. Within the AWS console, go to:

Amazon API Gateway > Custom Domain Names

Delete all the conflicting domains there and redo the deployment steps again.

like image 162
Daniel Birowsky Popeski Avatar answered Dec 20 '22 21:12

Daniel Birowsky Popeski


When you create an API Gateway, it will create an underlying CloudFront distribution on your behalf. You may not see it in your AWS account, but it's there.

Also, domains used for CloudFront distributions must be globally unique. Which means that if someone else already has a CloudFront distribution for api.example.com, then you cannot use it as well.

So, you already said that you do not have an existing CloudFront distribution visible in your AWS account.

If you already have an API Gateway for api.example.com, then you cannot create a second one. If this is the case, you need to use a different domain, or delete the original one.

If you don't have an API Gateway for that domain, then someone else probably already has one. If this is the case, then you'll need to use a different domain.

like image 22
Matt Houser Avatar answered Dec 20 '22 21:12

Matt Houser