# How to create a publicly accessible static website and host it on Amazon S3

In this blog, we will create an S3 bucket and configure it for static website hosting. Amazon Simple Storage Service (Amazon S3) is a managed cloud storage solution that enables you to store data as objects in a bucket. Objects can be almost any data file such as documents, images or videos.

**Let us now deploy a static website in S3 :**

Prerequisites :

1. AWS Management Console
    
2. An internet connection
    
3. An Internet browser such as Chrome or Firefox
    

### **Step 1: Creating a bucket in Amazon S3**

In the AWS Management Console, on the services menu, choose S3.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684516782042/44e1fc93-2caa-4669-aa7f-0dba3725a66d.jpeg align="center")

**Create Bucket :**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684517140239/172669f2-95c6-4ae7-98d9-ee4ff87fc141.jpeg align="center")

Choose create bucket. The bucket name should be globally unique. After you create a bucket, no other AWS accounts in any AWS Regions can use the name of that bucket unless you delete the bucket.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684517495667/c26415f9-f124-485a-ac77-b7db3fe7976f.jpeg align="center")

Give name to your bucket as shown above in the picture.

For **Object Ownership**, choose **ACLs enabled**.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684518052424/93b4b37e-11ed-4185-8423-67b4a5f252ed.jpeg align="center")

**Choose Bucket Owner Preferred.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684518229873/9d4c8e4c-4020-448c-bdcd-2b0f8b02c7ec.jpeg align="center")

For **Block Public Access settings for this bucket**, clear the check box for **Block all public access**, and then select the box that states **I acknowledge that the current settings might result in this bucket and the objects within becoming public.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684518541266/79e5b6f8-0f4d-46d5-a53f-af226a7444e2.jpeg align="center")

For bucket versioning, choose **Enable.**

Choose **create bucket.**

In the buckets section, choose the name of your new bucket for now it is shashank-14

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684519422931/03ade12a-34c1-49ec-b961-6326c1eafaac.jpeg align="center")

### **Step 2: Configuring a static website on Amazon S3**

We will now configure the bucket for static website hosting.

Choose the properties tab.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684519580171/79ead56b-25cf-43ab-aa57-e1350f6102c4.jpeg align="center")

Scroll to the **Static website hosting** panel.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684519816624/ee586500-7a93-4706-acb8-7beb899dd932.jpeg align="center")

choose **Edit** option.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684520070943/8978a19b-9556-4f70-a2fd-eb23207f9131.jpeg align="center")

Configure the following settings:

* **Static web hosting:** Choose **Enable**.
    
* **Hosting type:** Choose **Host a static website**.
    
* **Index document:** Enter `index.html`
    
* **Error document:** Enter `error.html`
    

**Note**: You must enter `index.html` and `error.html` even though they are already displayed.

Choose **Save Changes.**

In the **Static website hosting** panel under **Bucket website endpoint**, choose the link.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684520519455/49033edb-c0a9-4b5d-ad2d-73f7a72fa5b7.jpeg align="center")

You receive a *403 Forbidden* message because you have not yet configured the bucket permissions. Keep this tab open in your web browser so that you can return to it later.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684520630103/145b1e4d-fbc5-4504-bf18-4a5feba4eb75.jpeg align="center")

### **Step 3: Uploading content to your bucket.**

Return to the Amazon S3 console, and choose the **Objects** tab.

Choose **Upload**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684521002822/120c014a-7911-4bbe-a7d6-b85f2401eb4e.jpeg align="center")

Choose **Add files**

Add the files to showcase on the website.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684521231187/9fbba101-6e2d-4a25-b391-14689433276d.jpeg align="center")

Choose **Upload** option at the end.

Your files are uploaded to the bucket.

Choose **Close.**

### **Step 4: Turning on public access to the objects.**

You now configure the individual objects to be publicly accessible.

Choose all the files you uploaded.

In the **Actions** menu, choose **Make public using ACL.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684521995345/438edea2-e5d6-47a0-a28a-9e3180d30c2d.jpeg align="center")

Choose **Make Public.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684522104909/87a2244e-1245-45f0-8ad1-2a7014e91136.jpeg align="center")

Your static website is now publicly accessible.

Choose **Close.**

Again, In the **Static website hosting** panel under **Bucket website endpoint**, choose the link.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684522236251/694d4f34-d5cc-4c54-ad73-288c7f9b1f7d.jpeg align="center")

You should now see the static website that is being hosted by Amazon S3.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684522428199/83c6ce54-151b-46d6-b441-4abaaa9c430d.jpeg align="center")

Congratulations !! You have successfully deployed your static website in Amazon S3.

Thank you for your time.
