How to configure S3 to host a static website?

In the present day, AWS is widely recognized by the majority of people. It is a highly secure cloud services platform that provides a range of services, including computing power, database storage, and content delivery, as well as various platform services like Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS).

S3 stands for Simple Storage Service, which is a cloud storage service offered by Amazon Web Services (AWS). S3 provides a highly scalable and durable object storage infrastructure, which enables individuals and organizations to store and retrieve large amounts of data and files from anywhere on the internet. S3 is designed to be highly available, secure, and accessible, making it a popular choice for storing various types of data, including backups, archives, log files, multimedia content, and big data sets. S3 also supports a range of features, such as versioning, encryption, access control, and lifecycle policies, to help users manage their data efficiently and securely.

In this guide, I’ll be explaining the steps to host a static webpage on Amazon S3.

To start, we’ll need to create a bucket which is essentially a folder for object storage in Amazon S3.

Here are the steps to follow:

  1. Create a bucket with a name of your preference and select the region where you want it to be located.
  2. Enable static web hosting in the bucket by going to “Properties.”
  3. Under the “Edit static web hosting” section, select “Host a static website” and add the name of your index file (e.g., index.html, hello.html) and error file (error.html).
  4. Upload your index file and error file to the bucket.
  5. To make them publicly accessible, go to “Objects,” select the objects (index and error file), and click on “Actions” >> “Make them public.”

To check your static website content, obtain the URL for your bucket from Bucket Properties, Static Website Hosting section. For example, http://yourdomain.com.s3-website.ap-south-1.amazonaws.com
If you want to access the site using a domain name, you’ll need to add a CNAME record for the domain to point to the AWS bucket.
That’s it! By following these steps, you’ll be able to host a static webpage on Amazon S3. To access the website with its own URL instead of the bucket URL, add a CNAME entry for the website to the S3 bucket.