Amazon S3 is a fast, inexpensive and simple storage service. However, not a lot of people know that it can be used to host static websites.
What is a static website? A static site can be built by simply creating a few HTML pages and publishing them to a Web server. They do not require any Web programming or database design.
Creating a bucket:
The first step is to sign up for an AWS account. Creating an AWS account is free and gives you immediate access to the AWS Free Tier. There are a few things you should know before creating a bucket:
- The name must be unique across all existing bucket names in Amazon S3.
- The name must not contain uppercase characters.
- The name must start with a lowercase letter or number.
- The name must be between 3 and 63 characters long.
- After you create the bucket you cannot change the name, so choose wisely.
To create a bucket, navigate to S3 in the AWS Management Console and hit Create Bucket. You will then have to enter the bucket name and region, set permissions and your bucket is ready.
Now, Go and enable Static Website Hosting for the bucket. You can do this by entering the bucket and go to properties tab.
Now, we’ll upload files for the website
Once you’ve uploaded
the files, it will appear in your bucket. However, you won’t be able to see it in your browser yet because everything in S3 is private by default.
To make it public, we will have to write a bucket policy in which we make every object that comes to the bucket is public. You can read how to write bucket policies here : https://aws.amazon.com/blogs/security/writing-iam-policies-how-to-grant-access-to-an-amazon-s3-bucket/
Now, select the bucket and go the properties tab. Select static website hosting and you’ll get the endpoint. That is the link to your static website.
Once Configuration Done,check the Endpoint Specified in the console.
You’re all done! You should now have a working static website, hosted on your S3 bucket. Updating the website should be easy, just upload files in your S3 bucket.
Contributed by :