Site Loader

In this post we will show you how you can host your static web page or web application on AWS (Amazon Web Services). You can obtain simple maintenable and cheap web hosting.

Login to AWS web console click Services and type to search field S3 and then select S3 Scalable Storage in Cloud. This brings you to your S3 dashboard.

S3 creates for each project so called bucket which is a place for your files. So let’s click Create bucket button.

In Create bucket window specify name and region and click Next.

So far skip all other pages by clicking Next and on the last page Review click Create bucket button.

Now you can see your new bucket in the list of all buckets. Simply click its name. This shows bucket detail page. Here you can upload files directly from your computer oven drag&drop or you can set properties and permissions of your bucket.

Click Properties button and then select Static website hosting card.

In next window you can configure the hosting. Select Use this bucket to host a website, then type index.html and click Save button. You can also notice a web address of your bucket, so called Endpoint. Please store it for later use.

Then back in bucket screen click Permissions and Edit button.

Then uncheck Block all public access item and click Save. You will also be asked to type confirmation of your chose.

Now the basic setup of your bucket is done. Go to Overview and upload your files by Upload button or by drag&drop your files from your computer. Please be aware that in the root of your bucket must be index.html file. This one will be loaded when anybody departs on your bucket web address.

Set bucket policy

Now in Permissions tab click Bucket Policy button and enter following policy:

    "Version": "2012-10-17",
    "Statement": [
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::YourBucket/*"

Do not forget to replace “YourBucket” with the real name of your bucket. Then click Save button.

Load bucket files by script

You might an AWS Command Line Interfaces on your computer. If not then I warmly suggest to do it, because it can help a lot even with many other AWS tasks. The link is here:

Then you can upload a content of any folder of your computer very easilly. The command is:

aws s3 sync YourFolder s3://YourBucket --region us-west-2 --cache-control "no-cache, max-age=1"

Do not forget to replace “YourFolder” by your real folder including path and “YourBucket” by a name of your S3 bucket.

Test your website

Anyway even manually or by Aws-cli you files should be displayed in your bucket.

Now open your internet browser and type public web address of your bucket. If you do not remember the address simply go to Properties, then click Static website hosting and copy url at Endpoint.

Happy browsing!

Post Author: michalv

Leave a Reply

Your email address will not be published. Required fields are marked *