Creating a Public Website with S3
This guide provides step-by-step instructions on creating a public website using Amazon S3.
Hafeez Baig
32 steps
3 minutes
Amazon Web Services
Refer to the following guide to learn how to use IAM in the cloud\ <https://scribehow.com/shared/Creating_an_IAM_User_and_User_Group_in_AWS_Management_Console__hWNiiXlcRJKFqYZZEJD-cg> Refer to this guide to learn how to create an S3 Bucket\ <https://scribehow.com/shared/Creating_an_S3_Bucket_and_Exploring_the_UI__0TFMdpbkQvS6jOisdkQjeA>
1
Sign in to **AWS Management Console** as an **IAM User** **Pre-requisite** - Ensure you have selected the AWS region closest to your location\ For this guide, we will be using us-east-2 (Ohio) as a preferred choice
2
Type **S3** in the search bar and click on **S3** to view the S3 Dashboard
**What is Amazon S3 in AWS?** Amazon Simple Storage Service (Amazon S3) is a scalable object storage service offered by Amazon Web Services (AWS). It is designed to store and retrieve any amount of data from anywhere on the web.
3
**Amazon S3** dashboard will open, click on the "**my-aws-bucket-in28minutes**"
4
**my-aws-bucket-in28minutes** wizard will open, click on the **Properties** tab
5
Scroll to the **Static website hosting** section
**What is Static website hosting in S3?** Static website hosting in Amazon S3 allows you to host static websites directly from your S3 buckets. A static website typically consists of HTML, CSS, JavaScript, images, and other client-side assets that do not require server-side processing.
6
On the right side click on the **Edit** button
7
**Edit static website hosting** wizard will open, select the option **Enable**
8
Scroll to the **Index document** section and type "**index.html**" in the text input field
9
Scroll the page and click on the **Save changes** button
Congratulations on successfully enabling static website hosting in S3!
10
To upload the files for hosting, click on the **Objects** tab
11
On the right side click on the **Upload** button
12
**Files and Folders** wizard will open, select the files and click on the **Open** button
13
You can view all the files have been added
14
Scroll the page and click on the **Upload** button
15
From the Files click on the **index.html**
16
**index.html** wizard will open, scroll to the **Object URL section** and click on the copy widget to copy the URL
17
Paste the URL in the new tab
18
You will see **Access Denied** in the XMLformat
You're receiving an **Access Denied** message because the block public access setting is enabled.
19
To disable it, on the **my-aws-bucket-in28minutes** wizard and click on the **Permissions** tab
20
Scroll to the **Block public access (bucket settings)** section
**What is Block public access in S3?** Block Public Access is a feature in Amazon S3 that allows you to prevent accidental exposure of your S3 data to the public internet.
21
On the right side click on the **Edit** button
22
Remove the tick from the **Block all public access** checkbox and then click the **Save changes** button.
23
**Edit Block public access (bucket settings)** wizard will open, type "**confirm**"in the text input field click on the **Confirm** button
24
Successfully edited **Block Public Access settings** for this bucket
Congratulations on successfully disabling block public access!
25
Scroll to the **Bucket policy** section
**What is Bucket policy?** A bucket policy in Amazon S3 is a JSON-based resource policy that defines permissions for an S3 bucket. It allows you to control access to your bucket at the bucket level, specifying who can access the bucket and what actions they can perform.
26
On the right side click on the **Edit** button
27
**JSON Code for Bucket policy:**\ \ {\ "Version": "2012-10-17",\ "Statement": \[\ {\ "Sid": "PublicReadGetObject",\ "Effect": "Allow",\ "Principal": "\**",\ "Action": "s3:GetObject",\ "Resource": "arn:aws:s3:::yourbucketname/\**"\ }\ \]\ }
28
Paste the above JSON code in the **Policy** section
29
Copy the bucket name from the **Bucket ARN**
30
Scroll to the **Policy** section and in the JSON code paste the copied bucket name in the place of ***yourbucketname***
31
Scroll the page and click on the **Save changes** button
32
Reload the object URL page, you will see the page **My Todo List** web page
Congratulations on successfully creating a public website with S3 and exploring various permission settings to complete this lab!