Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possbile Issue: Failing to add CNAME to CloudFront distribution #95

Open
dciphered opened this issue May 16, 2021 · 4 comments
Open

Possbile Issue: Failing to add CNAME to CloudFront distribution #95

dciphered opened this issue May 16, 2021 · 4 comments
Labels
question Further information is requested

Comments

@dciphered
Copy link

Hi guys,

I've been experiencing an issue with the initial deployment procedure, namely the script failing when attempting to add a custom domain to the CloudFront distribution.

Firstly, because of the ACM region restrictions, I've created an new public certificate in the us-east-1 region that matches the custom domain that I plan to utilise for images (e.g. img.domain.com). However, I've specified the region within the settings yaml file as eu-west-2.

The CUSTOM_DOMAIN parameter has been set to reflect the cert name/SAN and the ACM_CERTIFICATE_ARN parameter has been set to reference the new certificate in the format of: arn:aws:acm:us-east-1:12345678:certificate/abc123-abc123-abc123-abc123-abc123 (sanitised)

In short, the process fails each and every time with the following error:
An error occurred: CloudFrontDistribution - Resource handler returned message: "Invalid request provided: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements (Service: CloudFront, Status Code: 400, Request ID: ......

What am I missing?

Versions
Operating System: MacOS 10.15.7
Serverless Sharp: 2.1.1

@Mosnar Mosnar added the question Further information is requested label May 16, 2021
@Mosnar
Copy link
Collaborator

Mosnar commented May 16, 2021

I haven't used the custom domain functionality myself. Maybe @bs-thomas can provide some insight, since he authored the original feature?

@dciphered
Copy link
Author

Thansk @Mosnar - would be great to get some clarity on this issue. As a temporary workaround, I removed those parameters from the settings file and after the env was spun up, I manually added the CNAME and custom SSL cert to the CF distribution. Only problem is, when redeploying via the IaaC method, it overwrites the above changes and reverts back to using the default CF SSL cert.

Definitely needs some further debugging...

@Wintereise
Copy link

Confirmed, this still doesn't work (not even if you attempt to deploy it on us-east-1).

@bs-thomas
Copy link
Contributor

bs-thomas commented Jun 29, 2022

The logic seems to have broke after another contributor has added the ACM_CERTIFICATE_ARN feature in, to allow direct specification of a certificate by ARN.

I have re-programmed the logic as follows:

  • Check if there is ACM_CERTIFICATE_ARN provided. If so, use it to bind to CloudFront.
  • Otherwise, check if there is a CUSTOM_DOMAIN provided. If so, create a new certificate, and use it to bind to CloudFront.
  • Otherwise, assume there is no domain nor certificate binding. Just use the good ole CloudFront domain.

Sending in a pull request in just a bit.

bs-thomas added a commit to bs-thomas/serverless-sharp that referenced this issue Jun 29, 2022
… new certificate should be created and binded. Should fix Issue venveo#95 where CNAME cannot be binded due to certificate not being binded to CloudFront.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants