Course lesson

Create an AWS S3 Bucket for Hosting a Static React App

Creating an S3 bucket is a straightforward process. You just have to make sure that you are using a unique name. But, there are a couple of things you need to do in order to host a static site on an S3 bucket.

Duration
5 min
Access
Included
Transcript
Retained from source evidence

Creating an S3 bucket is a straightforward process. You just have to make sure that you are using a unique name. But, there are a couple of things you need to do in order to host a static site on an S3 bucket.

First, under the properties tab, you need to enable static website hosting. Make sure to provide the index document to your app.

Second, you need to add a bucket policy. You can find examples in the policy examples docs. In our case, we will use the example under "Granting read-only permission to an anonymous user"

Bucket policy that was copy pasted:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action":["s3:GetObject", "s3:GetObjectVersion"],
            "Resource:["arn:aws:s3:::DOC-EXAMPLE-BUCKET/*"]
        }
    ]
}