Deploying a static site to AWS/s3

This is other thing that is SO COMPLEX, but it shouldn’t be so hard. One of the hardest things is creating an account and verifying it with S3. Not even gonna go over that one.

It all comes down to a bucket. Then you gotta save you code, in the bucket. Once you do that, route your dns to the bucket, you should be absolutely gravy… except for that 403 FORBIDDEN ERROR.

REALLY IMPORTANT REMINDER

THE BUCKET NAME MUST MATCH EXACTLY THE URL OF YOUR SITE. IF YOU DO THIS PROPERLY, IT SEEMS AMAZON WILL FIGURE EVERYTHING OUT AS LONG AS YOU NAME YOUR BUCKETS RIGHT

Step 1: Create Your Bucket

Log in to S3, create your bucket.

Step 2: Click the Properties Tab and enable Static Web Hosting

When you create your bucket, you need to enable static hosting. Picture below.

Step 3: Upload an index.html

Open up your text editor, create a file called index.html with the following content.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Hello</title>
</head>
<body>
    <div id="root">
        Yo, dawg, decide my night!
    </div>
</body>
</html>

Open you bucket on S3, Click Upload, select the index.html file you just created. That’s your entry point to the site.

Step 4: Add a Bucket Policy for 403 forbidden

After this, you’ll receive a good ole public link to your bucket. Visit this link and you’ll see a 403 Forbidden. HURRAY. One way to AVERT the 403 forbidden is to make a bucket policy. Yesss, one of those fucking bucket policies, how could I forget.

Do I write, anyone can read this fucking bucket?

Looks like the bucket needs valid json, doy.

That wouldn’t quite work, but I tried it none-the-less. Fortunately, I’ve already done this once and I can copy my old shit that somehow works.

The last line, needs to match your bucket name after the :::.

Post Content