Launch a static website using Amazon S3
Amazon Web Services (AWS) offers a simple and cost-effective solution for hosting static websites using Amazon S3 (Simple Storage Service).This is a very good beginner project for those who are exploring AWS.In this guide, I will walk you through the process of hosting a static website on Amazon S3.
PREREQUISITE:
- An AWS account (sign up at https://aws.amazon.com/ if you don’t have one)
STEP 1: CREATE A S3 BUCKET
1.Log in to your AWS Management Console.
2.Navigate to the Amazon S3 service.
3.Click “Create bucket” to begin creating a new bucket.
4.Provide a unique name for your bucket and choose the region closest to your target audience or your residence region.
5.Uncheck ‘Block all public access’ to make all the objects in the bucket public.
6.Keep the default settings for the rest of the options and click “Create” to create the bucket.
STEP 2: ENABLE STATIC WEBSITE HOSTING
1.Once your bucket is created, select it from the list and go to the “Properties” tab.
2.Scroll down to the “Static website hosting” section and click “Edit.”
3.Select “Enable” for the “Static website hosting” option.
4.Enter the name of your default HTML file which you are going to use for hosting(e.g. “index.html”).
5.Click “Save” to save the changes.
STEP 3: UPLOAD THE WEBSITE CONTENT
1.In the bucket properties, navigate to the “Object” tab.
2.Click “Upload” to upload your website files to the bucket.
3.Drag and drop your website files into the upload interface.
4.Click ‘Upload’.
STEP 4:CONFIGURE BUCKET PERMISSIONS
1.In the bucket properties, go to the “Permissions” tab.
2.Under “Bucket policy,” click “Edit.”
3.Add the following bucket policy, replacing “your-bucket-name” with your actual bucket name:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
Like the example given above.
4.Click “Save” to save the bucket policy.
All the steps have been completed and the website is ready to view.
STEP 5: VIEW THE WEBSITE
1.Click on the index.html file from the Objects tab and Click ‘Open’ .
The website can be viewed and static hosting on AWS using S3 has been completed.