Project: Hosting a Static Website on AWS S3: A Step-by-Step Guide
Efficient and Cost-Effective: AWS S3 Hosting for Your Static Website
Table of contents
Goal:
In this project, we will demonstrate how to host a static website on AWS S3. Hosting a static website on S3 is a simple and cost-effective way to serve a website with high availability, scalability, and low latency. With AWS S3, we can store and distribute web content with ease, without the need to manage and configure servers.
Prerequisites:
Before we start, we should have the following prerequisites:
An AWS account
A registered domain name
A static website with HTML, CSS, and JavaScript files
Project Steps:
Create an S3 bucket:
Log in to the AWS Management Console and go to the S3 service
Click "Create Bucket" and follow the prompts to create a bucket with a DNS name
Configure bucket properties:
Enable static website hosting in the bucket properties
Specify an index document and error document for your website
Upload website files:
Upload your static website files to the S3 bucket
Configure bucket permissions:
Add a bucket policy to make the website files public
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicRead", "Effect": "Allow", "Principal": "*", "Action": [ "s3:GetObject", "s3:GetObjectVersion" ], "Resource": "arn:aws:s3:::<bucket-arn>/*" } ] }
Enable public access
Configure Route53:
Create a Public hosted zone
Configure with a domain registrar
Create Record:
Create a Record name with a CNAME record type in Route53 hosted zone
In the value, section add an S3 Bucket properties sections Static website hosting endpoint
-
Verify the website is working:
Visit your website's URL to ensure that your static website is working correctly
Website: http://www.portfolio.amolovhal.com/
Conclusion:
In this project, we demonstrated how to host a static website on AWS S3. By following the above steps, you can easily host a website with low cost, high availability, and scalability. AWS S3 makes it easy to manage and distribute web content without worrying about managing servers.