- go to S3 service.
- Name it something unique (e.g.,
maria-static-site-demo). - Choose a region close to you (e.g.,
us-east-1). - Keep Block Public Access ON (we’ll use CloudFront for secure access).
- Create your static website files (HTML, CSS, JS).
- Example:
index.html,style.css,script.js.
- Example:
- **index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Maria's Cloud Project</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Welcome to Maria's Cloud Project 🚀</h1> <p>This static website is hosted on AWS S3, delivered securely via CloudFront, and mapped with Route 53.</p> <button onclick="showMessage()">Click Me</button> <p id="output"></p> <script src="script.js"></script> </body> </html>
- style.css
body { font-family: Arial, sans-serif; background-color: #f4f6f8; text-align: center; margin-top: 50px; } h1 { color: #2c3e50; } button { background-color: #3498db; color: white; padding: 10px 20px; border: none; cursor: pointer; margin-top: 20px; } button:hover { background-color: #2980b9; }
- script.js
function showMessage() { document.getElementById("output").innerText = "Hello from AWS Cloud! 🌐"; }
- Make sure your
index.htmlloads correctly in your browser before uploading.
- Upload your static website files to your S3 bucket.
- Copy your bucket ARN (e.g., arn:aws:s3:::maria-static-site-demo). //- you’ll need it when creating the CloudFront Origin Access Control (OAC).
- Go to CloudFront console → Origin Access Control → Create OAC.
- Choose S3 as the origin type.
- Give it a name (e.g.,
MariaStaticSiteOAC). - Save it.
- Click on create CloudFront Distribution.
- In Origin domain → select your S3 bucket (use the REST API endpoint, not the website endpoint).
- In Origin settings select:
- Allow private S3 bucket access to CloudFront – Recommended
- Customize origin settings
- Customize cache settings
- Set to: Redirect HTTP to HTTPS
- Keep it as GET, HEAD
- This ensures CloudFront is the only service allowed to fetch objects from your bucket.
- Save and create CloudFront Distribution.
- Once the CloudFront Distribution is ready:
- click on your distribution ID → General Settings → Edit → Default root object → index.html (enter file name)
- Save changes
- Visit your CloudFront domain (e.g., dldx46bp7p6e1.cloudfront.net) //CloudFront works
- https://maria-static-site-demo.s3.amazonaws.com/index.html //S3 URL doesn't work
- You kept your S3 bucket private (Block Public Access ON).
- That means direct requests to the S3 URL (
https://maria-static-site-demo.s3.amazonaws.com/index.html) are blocked. - Only CloudFront, with its Origin Access Control (OAC), is allowed to fetch objects from your bucket.
- So the fact that your CloudFront domain works but the S3 URL doesn’t is proof that your security setup is correct.
- Secure HTTPS traffic
- Without a certificate, your site can only be served over HTTP.
- With SSL, CloudFront can serve your site over HTTPS, encrypting data between the browser and CloudFront.
- This protects users from eavesdropping or tampering.
- Custom domain support
- CloudFront’s default domain (
dldx46bp7p6e1.cloudfront.net) already has HTTPS enabled with Amazon’s certificate. - If you want to use your own domain (e.g.,
setwin.xyz), you need an ACM certificate for that domain.
- CloudFront’s default domain (
- In the AWS Management Console, search for Certificate Manager.
- Make sure your region is set to US East (N. Virginia) – us‑east‑1. //Even if your S3 bucket is in another region, CloudFront looks for SSL/TLS certificates in AWS Certificate Manager (ACM) in us‑east‑1 (N. Virginia) .
- Click Request a certificate → Request a public certificate.
- Enter your domain name(s): (Example:
setwin.xyz) - Add
www.setwin.xyzas well if you want both root and www versions.
- Choose DNS validation (recommended).
- This is easier because you’ll add a CNAME record in Route 53 (or your DNS provider).
- CloudFront will automatically detect validation once the record is added.
- Click request
- Go to AWS Console → Route 53 → Hosted Zones → Create Hosted Zone.
- Enter your domain:
setwin.xyz. - Choose Public Hosted Zone.
- Route 53 will generate 4 Name Server (NS) records automatically.
- If your domain is registered with a third‑party registrar (e.g., GoDaddy, Namecheap, Spaceship):
- Log in to Registrar → Domain Management → DNS/Nameservers.
- Replace Registrar’s default name servers with the 4 Route 53 name servers.
- Save changes.
- ACM Validation CNAME
- Go to Route 53 → Hosted Zone →
setwin.xyz→ Create record and add:- Name: CNAME name (from ACM) // make sure no domain duplicates
- Type:
CNAME - Value: CNAME value
-
A Record for Root Domain
- Name: (blank) (represents
setwin.xyz) - Type:
A – Alias - Alias target: your CloudFront distribution (
dldx46bp**871.cloudfront.net)
- Name: (blank) (represents
-
For Subdomain (Optional)
- Name:
www - Type:
A – Alias - Value: dldx46bp7p6e1.cloudfront.net (
dldx46bp**871.cloudfront.net) - Save the records and allow 5–30 minutes for DNS propagation.
- Once validated, ACM will mark the certificate as Issued, and you can attach it to your CloudFront distribution.
- Name:
-
DNS Propagation Check
- Enter:
_5899e95f7243bc637d8b55tgffdghvb.setwin.xyz - Use https://dnschecker.org:
- Type:
CNAME - Confirm that the value appears globally
- Enter:
-
Once ACM status shows Issued, go to CloudFront → Settings → General.
-
Add Alternate Domain Names (CNAMEs):
setwin.xyzwww.setwin.xyz
-
Select your ACM certificate.
-
Save
- Wait for DNS propagation.
- Visit
https://setwin.xyz// your static site should load securely via CloudFront. - Visit
https://www.setwin.xyz// should redirect to the same site if you added the CNAME. - Confirm the 🔒 padlock in your browser.
- Hosted static website files (HTML, CSS, JS) in a private S3 bucket with strict security controls
- Configured CloudFront with Origin Access Control (OAC) to ensure only CloudFront could access S3 content
- Improved performance using CloudFront caching, HTTPS redirection, and global edge locations
- Provisioned and validated a public SSL certificate in ACM (us‑east‑1) for the custom domain (setwin.xyz, www.setwin.xyz)
- Enabled secure HTTPS delivery of the site through CloudFront using the custom domain
- Integrated Route 53 by creating a hosted zone and updating registrar name servers for domain ownership
- Created DNS records to map the domain and subdomain to the CloudFront distribution
- Completed DNS validation for ACM, ensuring the certificate reached Issued status
- Attached the SSL certificate to CloudFront and mapped both domain names for secure access
- Verified the full setup end‑to‑end: site served securely via CloudFront, HTTPS padlock confirmed, and www redirected correctly to the root domain