DEV Community

Static Website Hosting in Amazon S3 with Deny of HTTP Requests Using S3 Bucket Policy

“ 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.

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
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

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Phase 2: Output of Deny the HTTP URL Requests

Image description

Image description

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. To learn more, read the Amazon S3 documentation.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (1)

Collapse
 
robinamirbahar profile image
Robina

Nice