In my last post, I shared the wrong link. It was the regular S3 object URL instead of the static website endpoint. That made me stop and ask: why use the static website endpoint at all, when the object URL is already HTTPS?
The answer is that I'm doing this challenge to understand how each piece works, and static website hosting was a stepping stone. It's the S3 feature that makes a bucket act like a website. The object URL, on the other hand, is just a direct link to one file. The website endpoint does behave like a real website, but it's HTTP only, which was my challenge for step 4.
This leads to one of my challenges for today, CloudFront.
What is CloudFront?
CloudFront is a web service that speeds up delivery of your content through a worldwide network of data centers called edge locations. Here's how it works with my S3 bucket:
A visitor requests my resume, and the request goes to the nearest edge location, which reduces latency.
If the file is cached there, CloudFront returns it right away.
If not, CloudFront fetches it from the origin (my S3 bucket), caches it for next time, and returns it.
Setting up the distribution
Step 1: I named the distribution and selected the single website option. This is the best choice for a resume, since one configuration for one site is enough.
Step 2: I chose Amazon S3 as the origin type and picked my bucket from the dropdown. I kept the box Allow private S3 bucket access to CloudFront checked because that means the bucket can stay private, so later, I could turn Block Public Access back on. Spoiler alert: by the time this post is up, the static website endpoint from my last post won't work anymore.
I used the bucket endpoint, not the website endpoint (the one with s3-website), because the website endpoint requires a public bucket. The tradeoff is that the bucket endpoint doesn't serve an index document, so I had to set resume.html as the default root object in CloudFront. With the website endpoint, that would have happened automatically.
Step 3: I used the recommended cache settings, since they're built for static files like my HTML and CSS. I was tempted to customize them so I could select the HTTP to HTTPS redirect, because I thought that matched the HTTPS requirement of the challenge. But I figured the recommended setting would cover that, and I confirmed it afterwards.
Step 4: The setup offered a Web Application Firewall. It's useful for blocking bots and attacks like SQL injection, but it's overkill here. My site has no database, forms, or logins, just two static files, so there's little to attack. It also costs extra, and I'm keeping this project as cost-efficient as possible. I decided the cost wasn't justified. I also set the price class to North America and Europe, which is cheaper. It limits which edge locations serve my site. People elsewhere can still reach it, but latency may be higher.
Testing it
Once the distribution finished deploying, I opened the cloudfront.net link and it loaded. In the Behaviors tab, I confirmed the viewer protocol policy redirects HTTP to HTTPS, so the recommended settings did cover it.
Then I turned Block all public access back on. This wasn't required by the challenge, but now that visitors go through CloudFront, my s3 bucket can be private.
In summary, S3 alone could serve my resume over HTTPS(using the object URL), but my files had to be public. With CloudFront, the bucket stays private, and I can use my own domain.
Here's the updated link: cloudfront-domain-resume
Adding a custom domain
I usually stop at one step, but today I did steps 5 and 6 together and pointed the distribution at a custom domain. I bought lois-aleghe-resume.com from Cloudflare because it was cheaper. Route 53 would have been more convenient since everything is in AWS, but it costs more overall, and I'm keeping this project cost-efficient.
Getting the certificate
I went to AWS Certificate Manager (ACM) to request a free certificate. A certificate is what lets browsers trust my domain over HTTPS. I requested it for both lois-aleghe-resume.com and www.lois-aleghe-resume.com, so either one works.
One catch: CloudFront is a global service, and it only looks for certificates in US East (N. Virginia). AWS documents this rule but doesn't say why. It's likely because CloudFront's settings are managed from that region. So even though my bucket is in Canada, I requested the certificate in us-east-1. Otherwise it wouldn't have appeared in CloudFront.
Proving I own the domain
ACM gives you a CNAME name and value for each domain, and you add them as DNS records at your DNS provider. I added them in Cloudflare and I learnt three lessons here:
Set the records to DNS only. Cloudflare's proxy is on by default, and validation fails with it on.
Paste the name without your domain, but keep everything else. Cloudflare adds
.lois-aleghe-resume.comautomatically. For thewwwrecord, I originally left off the.www, so it stayed on"Pending validation"until I fixed it.Don't delete these records afterwards. ACM uses them to renew the certificate automatically.
Connecting everything
Once the certificate was issued, I went to my distribution and added both domain names as alternate domain names and selected the certificate as the custom SSL certificate. Then in Cloudflare, I added two more CNAME records, @ and www, both pointing to my CloudFront domain, again set to DNS only. That tells browsers to send my domain to CloudFront, which fetches the resume from S3.
Here's the custom domain link: custom-domain-resume
What I learned
The certificate validation records don't send visitors anywhere, they only prove ownership.
The alternate domain name setting in CloudFront is what makes it accept my domain, and the DNS records are what send visitors to it. I need both.
DNS proxy settings matter. DNS only is the right choice here.

