Skip to content

This guide explains how to connect Amazon S3, Route 53, CloudFront, and SSL to serve a secure website.

Notifications You must be signed in to change notification settings

panwar100/aws-s3-cloudfront-ssl-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

aws-s3-cloudfront-ssl-setup

This guide explains how to connect Amazon S3, Route 53, CloudFront, and SSL to serve a secure website.

Prerequisites

  1. AWS Account
  2. Domain Name (registered in Route 53 or elsewhere)

Project Workflow Overview

  • Static Website Files: Store your HTML, CSS, and JS files in an S3 bucket.

  • Custom Domain: Use Route 53 to create and manage DNS records for your domain.

  • SSL Certificate: Secure the website with HTTPS using AWS Certificate Manager (ACM).

  • Content Delivery: Distribute content globally and enforce HTTPS using CloudFront.

  • Diagram:

    [Your Domain Name] <-----> [Route 53]
           |
           v
    [CloudFront (SSL)]
           |
           v
    [S3 Bucket (Static Website)]
    

Steps

1. Set Up an S3 Bucket

  1. Log in to the AWS Management Console.

  2. Navigate to the S3 service.

  3. Create a new S3 bucket:

    • Bucket Name: Match your domain name (e.g., yourcreativecorner.xyz).
    • Region: Select a region close to your audience.

Screenshot from 2024-12-25 19-06-01

  1. Enable Static Website Hosting:
    • Go to the bucket properties.

Screenshot from 2024-12-25 19-11-15

  • Select Static Website Hosting and enable it.

Screenshot from 2024-12-25 19-11-50

  • Upload your website files (HTML, CSS, JS, etc.).

Screenshot from 2024-12-25 19-10-13

2. Configure Route 53

  1. Navigate to Route 53 in the AWS Console.

Screenshot from 2024-12-25 19-34-28

  1. Create a hosted zone:
    • Click on "Create hosted zone."

Screenshot from 2024-12-25 19-34-48

  • Enter your domain name and other required details.

Screenshot from 2024-12-25 19-35-35

  1. Change the Nameservers:

    • Copy the nameservers provided by Route 53.

Screenshot from 2024-12-25 19-37-12

  • Update the nameservers with your domain registrar.

Screenshot from 2024-12-25 19-37-57

Screenshot from 2024-12-25 19-38-19

Screenshot from 2024-12-25 19-39-20

  1. Add a record set:
    • Record Type: A (Alias).
    • Alias Target: Set this to the CloudFront distribution (to be created later).

Screenshot from 2024-12-25 20-00-42 Screenshot from 2024-12-25 20-01-11

3. Add SSL (AWS Certificate Manager)

  1. Navigate to Certificate Manager in the AWS Console.

Screenshot from 2024-12-25 19-43-41

  1. Request a public certificate:

Screenshot from 2024-12-25 19-43-55

  • Add your domain name (e.g., yourcreativecorner.xyz).

Screenshot from 2024-12-25 19-44-57

  1. Validate the certificate via DNS:
    • Add the CNAME records provided by ACM to your Route 53 hosted zone.

Screenshot from 2024-12-25 19-46-52 Screenshot from 2024-12-25 19-47-05 Screenshot from 2024-12-25 19-47-59

4. Create a CloudFront Distribution

  1. Navigate to CloudFront in the AWS Console.

Screenshot from 2024-12-25 19-52-39

  1. Create a new distribution:
    • Origin Domain Name: Select your S3 bucket.

Screenshot from 2024-12-25 19-53-39

  • Viewer Protocol Policy: Redirect HTTP to HTTPS.
  • Default Root Object: index.html.

Screenshot from 2024-12-25 19-54-57

  1. Attach the SSL certificate:
  • Use the certificate created in ACM. Screenshot from 2024-12-25 19-56-12
  1. Deploy the distribution.
  • Wait for the distribution to deploy. Screenshot from 2024-12-25 19-59-14

5. Test the Setup

  1. Visit your domain in a browser.
  2. Ensure the site loads securely over HTTPS.

Screenshot from 2024-12-25 20-18-38


Troubleshooting

  • S3 Bucket Permissions: Ensure the bucket policy allows public read access if needed.
  • CloudFront Cache: Clear the cache after updates to S3.
  • DNS Propagation: Allow up to 24 hours for DNS changes to take effect.

Useful Commands

  • Clear CloudFront cache:
    aws cloudfront create-invalidation --distribution-id YOUR_DISTRIBUTION_ID --paths "/*"
  • Check DNS records:
    nslookup example.com
    
    

About

This guide explains how to connect Amazon S3, Route 53, CloudFront, and SSL to serve a secure website.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published