Guide to create a Website on AWS
Hey Readers,
My name is Akshay, and I am working as Senior Developer at Luxoft India. Here in this article I will be trying to explain how we can create a website on AWS. This came as part of my project work at Luxoft which enabled me to learn skill in AWS and prepare this article.
Creating a website on AWS is very simple yet very interesting for a beginner. There isn’t much pre-requisites here for building a website on AWS, just by following these basic steps we can easily create it.
For creating a website on AWS we’ll be launching a static website using two AWS Services: Amazon S3 and Amazon route 53. There are 3 main steps involved in this process:
- Creating a custom domain name using Route 53.
- Using an Amazon S3 bucket to host a sample website.
- Enable static website hosting connected to the domain name and to view our website.
Step 1: Starting off, open up the AWS console and locate the ROUTE 53. Click this and open the dashboard.
On opening the Dashboard, Click on the Registered domains(as highlighted below). Since we’re going to start off by purchasing a domain name.
This will open a new window, now click on the REGISTER DOMAIN at the top of window. This will open a new window as below
Provide the domain name you’d like for like “medium”. From the drop down choose “.click” and the reason choosing “.click” is because it’s the cheapest one available. Click on “check” for availability, list of available domain will appear and then add it to cart.
Next is to fill in your contact details.
Now the final stage is to accept the terms and conditions, when you’re on this page make sure you click disable when asked if you want to automatically renew your domain that way you won’t be charged after one year once your domain expires accept the terms and conditions and complete order.
The domain registration might take up to three days.
Step 2: Next step is to go to the Amazon S3 page and create a bucket so this bucket will be used to host our website. Once you click on create bucket, type in the domain name that you registered in bucket name.
For the region you can select a region that is closest to where you live in order to make sure that you can reduce latency.
Now scroll down to the bottom and uncheck this Block Public Access setting, this is to make sure that the users will have access to your bucket and make sure it’s publicly accessible to others on the internet. Acknowledge the warning and keep all the other settings as default.
After this your bucket will get created. Click into your own bucket and then select upload. Here we’re going to upload our website and as an example to keep it very simple and just have a single page as the website.
Browse the file and upload the html file. The page will be uploaded.
Next we’re going to do is make sure that this bucket is enabled for static website hosting and making sure that it has the right permissions for users to access it. Now click on properties of your bucket as per previous screenshot on 2nd tab. Scroll all the way to bottom. By default its “Disabled” click on Edit and enable it.
Now in the “Index document” section type in the index document in my case index.html. Click save changes.
Next thing we need to do is on permissions tab of your bucket, we need to attach a bucket policy so click edit and put in a bucket policy.
Copy the below bucket policy and provide your own bucket name in line “arn:aws:s3:::Bucket-Name/*”, this will make sure that the policy works. Click save changes and now we have configured the bucket to have the sample website publicly accessible for viewers.
{
“Version”: “2012–10–17”,
“Statement”: [
{
“Sid”: “PublicReadGetObject”,
“Effect”: “Allow”,
“Principal”: “*”,
“Action”: [
“s3:GetObject”
],
“Resource”: [
“arn:aws:s3:::Bucket-Name/*”
]
}
]
}
Open the website from the object created as in my case open index.html and then click on OPEN. This will open up the website.
At this point we have hosted the website on Amazon S3 but as you can see above on the URL it’s not your custom URL this is a Amazon provided URL. To achieve this we will have to redirect our website to S3 bucket, in order to do this we will have to go back to route 53.
Step 3: On the AWS Console type Route 53 and open the dashboard. Click on the Hosted Zone
On clicking the hosted Zone our domain name will appear. At this point when we click on our domain name, we’ll need to add an additional record. This record is to make sure that the bucket will be connected to the Route 53 domain name. Click on Create record and choose the simple routing policy
Now we’re going to Define a simple record. Provide the values as per below on pop-up. Select region as per your preference. Also your S3 endpoint will already provided so you can select easily from drop down.
Then create the record by clicking Define simple record and just double confirm by clicking on Create records on next page. Wait for few minutes to propagate the changes. Now refresh the website, you would be able to see the custom domain and you can see that it’s pointing to the S3 bucket and showing the same message on website.
Thanks for reading and I hope you would have loved this article, please let me know in comments in case of any queries. Please do share reviews as well.