0
votes

I have a website setup in E2E having cPanel with the domain https://example.com. The images for the website are stored in an s3 bucket in AWS.

My final goal is to make the images in the s3 to be accessible as https://images.example.com/cake.jpg

For this, I have created a cloudfront distribution in AWS and made the images to be accessible with the cloudfront URL https://d1234.cloudfront.net/cake.jpg. But the next part, I do not know how to map the subdomain images.example.com to d123.cloudfront.net. Should I use the Alternative domian name setting in cloudfront as shown in the image below. The domain is setup in E2E so I'm not sure what to add in the CNAME field there.

enter image description here

Or should I just create an A record in E2E to map images.example.com to d123.cloudfront.net. If so, how can I add the SSL to images.example.com and force the SSL redirect from http to https?

1

1 Answers

1
votes

You actually need to do both.

First within CloudFront you need to add the Alternative Domain Name(s) that you would like to use for your CloudFront distribution. Make sure to generate a certificate in ACM within us-east-1 that covers the domains you're going to setup.

Once this has been applied within your DNS provider you then need to create a record with the exact domain name specified (in Route 53 this would be Alias, in other providers a CNAME) and then give it the value of the CloudFront domain name.

If the alternative domain name is not featured in your CloudFront distribution traffic will be denied when you attempt to resolve the domain.

For more information follow the Using Alternate Domain Names and HTTPS documentation.