HOSTING A STATIC WEBSITE, USING AWS S3 BUCKET.
Tags: aws, s3
Published: 2024-02-16 12:40:55


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fr798u6ulcy78fvtc1xl.png)

There are two different types of website namely : Static website and Dynamic website.For the purpose of this article the main focus will be on static website, which is a type of website that is made up of fixed files, such as HTML,CSS, JavaScript, files and images. 

Introduction

## WHY USE AN S3 BUCKET TO HOST A STATIC WEBSITE?

1. Highly reliable: S3 provides durability and availability for your data.It store multiple copies of your files across different servers and facilities, reducing the risk of data loss.It also offers automatic backups built in redundancy.

2. Scalable: S3 is highly scalable which means it can handle large amounts of data and traffic without any issues. Either the website has a few visitors or millions.

3. Cost effective: S3 offers a pay as you go pricing model, which means you only pay for the storage and data transfer you use. It eliminates the need for upfront hardware cost and allows you to scale your storage based on your needs.

Step by step illustration on hosting a static website using S3.

Create an AWS account so has to have access to S3 service and other AWS service at large.
https://portal.aws.amazon.com


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1af3ywopo6k3tp6ndufc.png)

Click "create bucket"


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/buc69ajilpc1ml6s3sjb.png)

Use a unique name for bucket, it serves as a globally unique identifier for your bucket. Also select the appropriate region you want the bucket to be hosted.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/db9cq6f10gjzfxy5kc0m.png)

Scroll down, click on Access control lists (ACLs) and object writer enabled.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87pshp6jflbxiayrpsop.png)

Deselect "Block all public access" 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su9f8cx2sj72muoer1et.png)

 All other option should be kept on default and click "create bucket" 

Click on the already created bucket and click upload.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1z8bnupq9okd9aasjat.png)


Following, Get your existing files to add the css, javascript files and css and upload in your bucket.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mnbaxr847749yvyqessj.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhll2d2cpmpvrscx4jb7.png)

Click on properties tab, scroll down to static hosting and select "Enable" to activate static website hosting. Type (index.html). 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7gwfo3dcnmxxhvds2aw.png)


In conclusion, Click on objects tab and select all the uploaded website files, then click actions, scroll down and click "Make public using ACL"


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6klbfkwsgkk7qzbp363.png)

Finally, you have successfully hosted your static website on Amazon S3.To view the result click on properties and scroll down, copy the endpoint and paste on your browser to access your website.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/149bt3tf8mcbig2zbej3.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lq6qrrb1idjimymtqcgn.png)


## As we draw curtains on this discussion, i hope you have learnt how to host a static website using Amazon S3.