HOW TO HOST A STATIC WEBSITE ON S3?
Tags: aws, cloud, learning
Published: 2024-02-22 20:33:09



-**STEPS TO HOST A STATIC WEBSITE ON S3:**
1.OPEN S3 BUCKET FROM THE SERIVES OF AWS ON LOGIN CONSOLE.THE FOLLOWING SCREEN WILL APPEAR:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ysdnnh39a84ne9g4hew8.png)!

- Now Before creating a Bucket you must remember rules for naming a bucket. click the link below to see the rules for naming a variable .
https://docs.aws.amazon.com/console/s3/bucket-naming
2. Now after that click on **Create Bucket** 
the following screen will appear.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6m14usfll31f0fw2yug.png)
3.Now select the Region where you want to create a Bucket.Like in this case "US East (N. Virginia) us-east-1".
4. After that Enter the  name of the bucket that must be "Unique Globally". Like in this case "safi1234" and create a default bucket witout more changing.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/le6pq6j8qvpnqm2j3ht6.png)
5.Now after that click on Bucket and upload the object on Bucket on the following screen.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/otelthlwglweehsbvxby.png)
6.Now after uploading your static website files the following screen will appear

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pcxb2clbda1wcfhcn54.png)
7.Now after that go back to the bucket and you can see on the picture "Bucket and object is not public" below there is

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkdcwtalxgxqxbiqd1ln.png)
Now the first step is to make it public go the "Permission" option on bucket and uncheck the box "Block public access and click on "save changes".
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfkr0335503nlt8w8tx8.png)"
8. Now after that the next point is go to "Object Properties" 
and enable "Static Website Hosting".The following screen will appear

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdx86civ410rgumcdavb.png)
9.Now after that we have to create a bucket policy for this go to "Edit Bucket Policy" inside the permission option the following screen will appear

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ltp2zwhpl2dd88ja4jr.png)
10.after that click on edit and copy the "Amazon Resource name(ARN)".The following screen will appear.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi5frp93i9crt8418xux.png)
11.Now the next step is to write a policy for bucket or generate policy for bucket by default. In this case we generate the policy of bucket by default.click on "Generate Policy" The following screen will appear. In this we have paste the "ARN(Amazon Resource name)".And action selected "Get Object".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fp40agotudi720h2b6vo.png)
12.After that click on generate policy and copy the policy and paste it here and add "/*"at the end "Resource" the following screen will appear

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wuvlyc1382tvee4693h7.png)
And click on "Save changes."

13.Now at the end copy the link from here and open new tab and paste the link like in this case "http://safi1234.s3-website-us-east-1.amazonaws.com/" the following screen will appear.


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


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


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3arvjm76h5reo2qw3rhi.png)
  
SO finally "we have host our static Website on S3."