How use CloudFront or any other AWS tools to get it.

Certainly! Let's go through the process step-by-step to host your static HTML file on AWS S3 and then use AWS CloudFront to deliver it via your domain tactlocal.com.

Step-by-Step Guide with Example

Step 1: Create Your HTML File and Upload to S3

First, create your static HTML file (index.html) as mentioned earlier. For this example, we'll use the same simple HTML content:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Static HTML on AWS S3</title>
</head>
<body>
    <h1>Hello, AWS S3!</h1>
    <p>This is a static HTML file hosted on AWS S3.</p>
</body>
</html>

Upload this index.html file to your AWS S3 bucket following the steps mentioned in the previous response.

Step 2: Configure S3 Bucket for Static Website Hosting

Ensure your S3 bucket is configured to host a static website:

  • Open your S3 bucket in the AWS Management Console.

  • Go to the "Properties" tab.

  • Click on "Static website hosting".

  • Select "Use this bucket to host a website".

  • Enter index.html (or the name of your HTML file) as the Index document.

  • Optionally, you can specify an Error document if needed.

  • Click "Save changes".

Step 3: Set Permissions (if not already done)

Make sure your S3 bucket and objects (including index.html) are publicly accessible:

  • Go to the "Permissions" tab of your bucket.

  • Click on "Bucket Policy".

  • Add a policy that allows public read access to your bucket and its objects. Here’s an example policy:

Replace "my-static-website-bucket" with your actual bucket name.

Step 4: Create an AWS CloudFront Distribution

Now, let's use AWS CloudFront to distribute your static website and connect it to your domain tactlocal.com:

  • Go to the AWS Management Console and navigate to CloudFront.

  • Click on "Create Distribution".

  • Select "Web" as the delivery method (this is for delivering websites and other content).

  • Click on "Get Started" under the "Web" section.

Step 5: Configure CloudFront Distribution

Configure the CloudFront distribution settings as follows:

  • Origin Settings:

    • Origin Domain Name: Select your S3 bucket from the dropdown (e.g., my-static-website-bucket.s3.amazonaws.com).

    • Origin Path: Leave this blank unless your files are stored in a subdirectory within the bucket.

    • Origin ID: This is automatically populated based on your selection.

  • Default Cache Behavior Settings:

    • Viewer Protocol Policy: Choose "Redirect HTTP to HTTPS" if you want to enforce HTTPS.

    • Allowed HTTP Methods: Select "GET, HEAD" to allow these methods for accessing your content.

    • Leave other settings as default unless you have specific requirements.

  • Distribution Settings:

    • Alternate Domain Names (CNAMEs): Enter tactlocal.com.

    • SSL Certificate: Choose either "Default CloudFront Certificate" (if you don't have a custom SSL certificate) or "Custom SSL Certificate" (if you have one provisioned in AWS Certificate Manager).

    • Default Root Object: Enter index.html.

    • Logging: Configure logging if needed.

  • Click "Create Distribution".

Step 6: Update DNS Settings for tactlocal.com

After creating the CloudFront distribution, AWS will assign a domain name (e.g., d123456789.cloudfront.net). You need to update the DNS settings for tactlocal.com to point to this CloudFront distribution:

  • Log in to your DNS provider where tactlocal.com is registered.

  • Create a CNAME record pointing www.tactlocal.com (if using www) or directly tactlocal.com (if using apex domain) to the CloudFront domain name (d123456789.cloudfront.net).

Step 7: Testing

Wait for the DNS changes to propagate (this can take some time, usually up to 48 hours depending on your DNS provider). Once propagated:

  • Open http://tactlocal.com in a web browser. It should now serve your static HTML file via AWS CloudFront.

Last updated