How to Set Up a Static Website on Amazon S3

How to Set Up a Static Website on Amazon S3

2 min read

Step 1: Create an S3 Bucket

1. Log in to AWS Management Console and navigate to the S3 service.

2. Click "Create bucket".

3. Configure the bucket:

  • Bucket name: Enter a globally unique name for your bucket (e.g., my-unique-bucket-name).

  • Region: Select the AWS region where you want to create the bucket.

4. Click "Create bucket".

Step 2: Upload Your Website Files

1. Select your newly created bucket.

2. Click "Upload".

3. Click "Add files" and select your website files (HTML, CSS, JavaScript, images, etc.).

4. Click "Upload" to upload your files to the bucket.

Step 3: Configure Bucket Permissions

1. Navigate to the Permissions tab of your bucket.

2. Click "Bucket policy" and add the following policy to make the bucket contents publicly accessible:

```json

{

"Version": "2012-10-17",

"Statement": [

{

"Effect": "Allow",

"Principal": "*",

"Action": "s3:GetObject",

"Resource": "arn:aws:s3:::my-unique-bucket-name/*"

}

]

}

```

Replace my-unique-bucket-name with your actual bucket name.

3. Click "Save".

Step 4: Enable Static Website Hosting

1. Go to the Properties tab of your bucket.

2. Scroll down to the Static website hosting section.

3. Click "Edit".

4. Enable static website hosting:

  • Select "Enable".

  • Index document: Enter the name of your index file (e.g., index.html).

  • Error document: Optionally, enter the name of your error document (e.g., error.html).

5. Click "Save changes".

Step 5: Access Your Static Website

1. After enabling static website hosting, you will see an Endpoint URL.

2. Click on the Endpoint URL to view your static website.

That鈥檚 it! Your static website is now hosted on Amazon S3.馃殌