Static Website Hosting in Amazon S3 with Deny of HTTP Requests Using S3 Bucket Policy
Tags: aws, amazons3, website, httprequest
Published: 2024-01-13 19:21:24

“ I have checked the documents of AWS to enable the static website hosting in amazon s3 and create a s3 bucket policy to deny http requests. So I found that it can be possible using amazon s3 features and policy. Pricing of S3 bucket as per storage size.”

On a static website, individual web pages include static content. They might also contain client-side scripts. By contrast, a dynamic website relies on server-side processing including server-side scripts such as PHP, JSP or ASP.NET. Amazon S3 does not support server-side scripting but AWS has other resources for hosting dynamic websites. To learn more about website hosting on AWS see [Web Hosting](https://aws.amazon.com/websites/).

Bucket policies and user policies are two access policy options available for granting permission to your Amazon S3 resources. Both use JSON-Based access policy language.

In this post, you will get to know how static website hosting in amazon s3 with deny of http requests using s3 buckets policy. Here I have created a s3 bucket with static website hosting and s3 bucket policy to deny http requests.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ziaideodfzjp2hlgfdye.png)
The architecture diagram shows the overall deployment architecture with data flow, amazon s3 and website.

#Solution overview
The blog post consist of the following phases:
1. Create of S3 Bucket with Static Website Hosting
2. Output of Deny the HTTP URL Requests

##Phase 1: Create of S3 Bucket with Static Website Hosting 
1. Open the s3 console and create a bucket named “request-buck”. In the properties tab, enable the static website hosting with index.html file. Check the http url of the website using bucket website endpoint. In the permissions tab, open all public access with public read get object policy. Also keep the index.html file as an object in a bucket. Test the http url on the browser.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

##Phase 2: Output of Deny the HTTP URL Requests

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

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

#Clean-up
Delete S3 Bucket.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of S3 = $0.009

Total Cost = $0.009

#Summary
In this post, I showed “static website hosting in amazon s3 with deny of http requests using s3 buckets policy”.

For more details on Amazon S3, Checkout Get started Amazon S3, open the [Amazon S3 console](https://s3.console.aws.amazon.com/s3/get-started?region=us-east-1). To learn more, read the [Amazon S3 documentation](https://docs.aws.amazon.com/s3/?icmpid=docs_homepage_featuredsvcs).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)