Skip to content

This project will cover Amazon S3, Amazon CloudFront, AWS Certificate Manager, and Route 53. It's a great starting point for understanding how to serve web content on AWS at scale securely.

Notifications You must be signed in to change notification settings

johnlopez719/S3staticwebsiteDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table Of Content

Overview

For this lab, we are going to

  • Configure an Amazon S3 bucket for website hosting.
  • Secure your website with a free SSL certificate from AWS Certificate Manager.
  • Use Amazon CloudFront to distribute your content worldwide efficiently.
  • (Optional) Manage a custom domain with Route 53 and link it to your CloudFront distribution.

Lab Diagram

Slide7

Lab Instructions

1. Prepare Your Static Website Files

  • Ensure you have a static website (HTML, CSS, JavaScript) ready for deployment. If you don't have one, you can navigate to StaticWebsite folder which contains the necessary files.

2. Create an Amazon S3 Bucket for Website Hosting

  • Step 2.1: Sign in to the AWS Management Console and open the Amazon S3 console.
  • Step 2.2: Click "Create bucket". Provide a unique name for your bucket and select the AWS Region you want to host your site in.
  • Step 2.3: Uncheck "Block all public access" settings and acknowledge that the bucket will be publicly accessible.
  • Step 2.4: Click "Create bucket". Screenshot 2024-04-10 at 1 57 03 PM

3. Enable Static Website Hosting

  • Step 3.1: Select your newly created bucket and navigate to the "Properties" tab.
  • Step 3.2: Click on "Static website hosting" and select "Use this bucket to host a website". Enter the name of your index document (usually index.html).
  • Step 3.3: Save the changes. Screenshot 2024-04-10 at 1 58 11 PM

4. Upload Your Website Files

  • Step 4.1: Go to the "Objects" tab in your bucket and click "Upload".
  • Step 4.2: Add your website files and upload them to the bucket.

5. Set Bucket Permissions

  • Step 5.1: Navigate to the "Permissions" tab of your bucket.
  • Step 5.2: Edit the bucket policy to grant public read access to the website files. Use the AWS policy generator if needed, allowing GetObject permission for everyone.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource":"arn:aws:s3:::<bucket-name>/*"
            
            
        }
    ]
}

6. Register a Domain Name with Route 53 (Optional)

  • If you don't have a domain, you can register one directly through AWS Route 53.
  • Navigate to the Route 53 console and follow the process to register a domain.

7. Request a Certificate with AWS Certificate Manager

  • Step 7.1: Open the AWS Certificate Manager console.

  • Step 7.2: Click "Request a certificate", select "Public certificate", and follow the wizard to request a certificate for your domain name. Validate your domain via email or DNS. Screenshot 2024-04-11 at 5 21 08 PM Screenshot 2024-04-11 at 5 21 27 PM

  • Step 7.3: Once you request your certification you will be asked to validate your domain. To validate your domain click on "Create Record" and follow the wizard. Once you validate your domain your status will change from "Pending" to "Validated" (1-2mins). Screenshot 2024-04-11 at 5 22 07 PM Screenshot 2024-04-11 at 5 22 56 PM

8. Create a CloudFront Distribution

  • Step 8.1: Open the CloudFront console and click "Create distribution".

  • Step 8.2: Under "Origin domain" specify your S3 bucket's static website endpoint as the origin. Screenshot 2024-04-11 at 5 23 24 PM Screenshot 2024-04-11 at 5 23 34 PM

  • Step 8.3: Set Viewer protocol policy to Redirect HTTP to HTTPS. Screenshot 2024-04-11 at 5 23 56 PM

  • Step 8.4: Choose the SSL certificate you created with AWS Certificate Manager. Screenshot 2024-04-11 at 5 24 42 PM

  • Step 8.5: Set the CNAME to your domain name Screenshot 2024-04-11 at 5 24 21 PM

  • Step 8.6: Create the distribution. It may take some time to deploy (5-15min). Status should say enable and "last modified" should have a date. Screenshot 2024-04-11 at 5 28 46 PM

9. Update Route 53 to Point to Your CloudFront Distribution (If Using a Custom Domain)

  • Navigate to the Route 53 console.

  • edit your A record set to point your domain to the CloudFront distribution by choosing "Alias" and selecting the CloudFront distribution you created.

    Screenshot 2024-04-11 at 5 30 05 PM

10. Test Your Website

  • Once your CloudFront distribution is deployed, access your website using the CloudFront distribution domain name (or your custom domain if you've set it up).

Screenshot 2024-04-11 at 5 31 08 PM

Congratulations! You have deployed a static website on AWS, utilizing S3 for storage, CloudFront for global content delivery, secured with an SSL certificate from AWS Certificate Manager, and optionally using a custom domain managed by Route 53. 🥳

Resources

Inside the StaticWebsite folder, you will find an index.html, css, and javascript files to create a basic website.

About

This project will cover Amazon S3, Amazon CloudFront, AWS Certificate Manager, and Route 53. It's a great starting point for understanding how to serve web content on AWS at scale securely.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published