Home

Static Website

By Sotee Loey on Nov 24, 2023
Image post 7

Here are the steps I used to build static web site:

  1. Build my blog site in HTML, index.html.

  2. Create an S3 bucket the same name as domain name to store portfolio files.

    • Upload index.html file to S3 bucket.
    • Give permission for public access.
    • Add bucket policy.
    • Go to the S3 bucket and enable Static website hosting, and map the Index document and Error document.
  3. In Route 53, create A record that map to S3 website endpoint and choose the bucket that created in step 2.

  4. Requested a public certificate for your domain in AWS Certificate Manager(ACM).

  5. Setup a CloudFront Distribution. Select S3 Static website hosting bucket endpoint and ACM public certificate.

    • Change viewer protocol policy to redirect HTTP to HTTPS.
  6. Go back to Route 53, change the A record that point to S3 website end point to point to CloudFront distribution.

  7. Test website to make sure, it works properly.

Here you have it!

Bucket policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::www.goingaws.com/*"
            ]
        }
    ]
}

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Goingaws</title>
    </head>
    <body>
        <p>This is an example of a simple HTML static site.</p>
    </body>
</html>
Subscribe to my Newsletters

Stay up-to-date with new posts