Hey developers! In this article, I will show you step-by-step how to host a website on AWS S3 bucket. And the best part is, that you do NOT need a Webhosting or even a domain name for it. But the catch is, that it can ONLY host static websites and not dynamic ones. The difference between both is mentioned in detail here. So, without wasting any more words, let’s dive right in.
Prerequisites
- You should have already made an AWS account (Create one)
Table of Content
- Choose S3 Service in AWS Management Console
- Configuring a new S3 bucket on AWS
- Create a Static Website Template
- Upload data on AWS S3 bucket
- Enabling Static Website Hosting on S3 Bucket
- Allow Public Access to the Website on AWS
STEP 1: Choose S3 Service in AWS Management Console
To begin with, we need to create an S3 Bucket. It is the place where all our data is stored on AWS and is where we will host our website. Therefore, choose the S3 service in the AWS management console. Take reference from the image below:
This will open up the S3 bucket dashboard where all your buckets are listed. Here you will create a new bucket.
STEP 2: Configuring a new S3 bucket on AWS
Now then, when you come to the dashboard of the S3 bucket on AWS, you will see the “Create bucket” button on the top right. See the image below for reference. Click on it to begin the configuration of a new S3 bucket on AWS.
Here the configuration begins. As shown in the below image add the name of your bucket. Note that this should be the URL / domain name of the website you want to host. Then set its region; you may leave it as default too.
Next, keep the following public access rights as shown in the image below. Also, you should enable “Bucket Versioning”. This will allow AWS to keep separate copies of all the old and updated files and content that you upload of the same name. (Note: this will increase the size of your bucket).
Lastly, you will enable the “Default encryption” option as well. This will encrypt all the data that you store on the S3 bucket for security purposes. It will encrypt and decrypt automatically for you when you want to access it. Afterward, click on Create bucket and you’re done.
This image shows that your S3 bucket was successfully created on the AWS cloud.
STEP 3: Create a Static Website Template
For this article, we will create a basic HTML template file named “index.html”. Here is the boilerplate code for the index.html file.
Welcome to Programatically
This is a Live static website hosted on AWS S3 bucket