Table of Contents
Nowadays, most commonly everyone know about AWS. AWS is a secure cloud services platform that offers compute power, database storage, content delivery and several other platform services such as Infrastructure as a service(IaaS), Platform as a service (PaaS) and Software as a service(SaaS).
What is S3?
S3 means Simple Storage Service. It’s also one of the service provided AWS. It’s a storage service. We can store and retrieve any amount of data at any time, from anywhere on the web. Amazon S3 stores data as objects within buckets. Bucket is simply folders that we can access. Apart from this, one other use of S3 is, we can host static website in S3.
Here I’m explaining how we can host a static webpage in Amazon S3.
First, we need to create a bucket.
Bucket is simply a folder for object storage in Amazon S3.
- Step 1. Create Bucket with the preferred name and select the region that you want to have your bucket.
- Step 2. Enable static webhosting in the bucket by navigating to “Properties“.
- Step 3. Choose “Host a static website” in Edit static webhosting section, add the name of your index file(eg: index.html,hello.html) and error file(error.html)
- Step 4. Now, upload your index file and error file to the bucket.
- Step 5. Finally, we need to make them publicly accessible. For that go to “Objects” and select the objects (index and error file)and click on Actions >> Make them public.
Here you go!! It’s the time to check your static website content. The URL for your bucket will be obtained from Bucket Properties, Static Website Hosting section.
For example: http://yourdomain.com.s3-website.ap-south-1.amazonaws.com
Now, if you need to access the site using a domain name, we need to add a CNAME record for the domain to point to the AWS bucket.
That’s it about adding hosting a static page!!
To access the website with its own rather than the bucket URL, we need to add a CNAME entry for the website to the S3 bucket.
I know, while reading this blog post, you might have think like, why? why we need to host a website on s3? Is it a good practice?
If you have a very basic website, which means a website with minimal information about your business you can definitely host that to s3. This is the simplest option to make live your web presence.
Another important use case, maintenance page
Adding a maintenance page for your website. Consider, you have a website without proper DR plan. If something goes wrong with your servers where you hosted your website, or you have a planned maintenance on the infrastructure, you can easily use your static maintenance page at s3 to put your websites under maintenance.
With minimal things, you can host a maintenance page at s3, and during the occasion of any incidents or planned maintenance you can point your sites to s3.