Hosting a static website on Amazon S3 (AWS howto)

Articles, Blog

Hosting a static website on Amazon S3 (AWS howto)

Hosting a static website on Amazon S3 (AWS howto)

Hello everyone! In this video I’m going to
show you how you can host static websites on Amazon S3. But before we do that, let’s
first take a look at what S3 is. Well S3 is a cloud storage service, built by Amazon,
that allows you to store an unlimited amount of files in the cloud. And being the cloud,
you of course only pay for what you use. So why would you use S3 instead of a regular
webhost? Well first of all S3 has great performance. It’s also very secure since you don’t have
PHP or a MySQL database running that can be compromised. It’s low cost in the sense that
you only pay for what you use and it can scale very well. It can scale from 1 request per
second to dozens of requests per second. So what’s next in this tutorial? I’m going to
show you how you can create a bucket. We’re going to enable the static website hosting
feature, we’re going to set a bucket policy allowing all our files to be accessed through
a browser. And than we’re going to test our website and see if it actually works. So let’s begin. So for the purpose of this video, I’ve created
a simple website that I’m going to host on S3, called “My awesome website”. And this
is what it looks like. It’s basically two simple pages with “Hello world, this is my
awesome website’s homepage. There’s even a second page which you check out here”. And
you can click and than it navigates to page2.html and than you can back if you want, back to
the homepage. Okay so let’s now host our static website
on Amazon. Let’s go to the AWS management console, which is at
And I’m going to open up the S3 management console here. As you can see I have a lot
of buckets where I can store files. And for my website I’m going to create a new bucket.
I’m going to click “Create Bucket” and I’m going to call it “”.
I’m going to leave the region by default, Ireland. I live in Europe so this is a very
good region. I’m not going to set up logging, so I’m just going to go for “Create”. And Amazon is now creating my bucket and boom,
there you have it. My bucket has been created. So the first thing that we’re going to do
is enable static website hosting for this bucket. So I’m going to click on “Static website
hosting” and I’m going to click “Enable” and now Amazon wants to know what our index and
error documents are. So my index document is very traditional, it’s called “index.html”
and my error document is called “404.html”. These are two files that should be in this
bucket, for the website to work. So I’m going to click “Save” and right now my bucket and
my website is accessible through this URL. So it’s called [reads URL]. So if I click
on it, I see “403 forbidden”. That’s pretty logical because there’s nothing in the bucket
yet. So let’s go into the bucket, let’s click on the name. And I’m going to upload some
files, so here I’m going to say “Add files” and I’m going to select all my files here,
my HTML files. You can’t actually upload folders to this but we’re going to do that manually.
Okay, so there are my files. Now I’m going to create a folder “CSS” and in that folder
I’m going to upload my stylesheet. And there you have it, my website is completely uploaded
to Amazon S3. Now let’s take a look if that website is already
up and running. So let’s go to my website and hit refresh. No, I still got “403 forbidden”.
Why is that? Well, Amazon makes sure that all the files that you upload are not publicly
accessible straight away. This is a security feature. You have two choices: either you
can make every file public – which you can do, you click on a file, open it’s properties
and than you can set the permissions and you can allow anyone to get your object OR you
can do this instantly for all files in your bucket. I think that’s a much nicer solution,
so let’s go for that! So to do that, let’s click on your bucket name and let’s go the
properties – which is by default selected – and we’re going to select “Permissions”.
We’re going to add a bucket policy. So now Amazon asks you which policy I have to add.
Well I have already created a policy here, which is stored on my desktop. And this is
the policy that you need to make all files in your bucket publicly accessible. I will
share this in the video’s description. So basically what you’re saying is that we’re
allowing anyone to read or get an S3 object, and we’re going to allow it for all files
in this bucket, which is the name of my bucket. So let’s save that and let’s save here as
well. And now if I’m gonna go back to my website and I hit refresh, sure enough there is my
website! Hello World! I can navigate to the other page and I can navigate back and all
is very well. Now let’s also test our error document. So here we navigate to “index.html”.
Let’s say I want to go to “blabla.html” which is a file that does not exist. If I hit enter,
Amazon automatically redirects me to my error document. I created this file: “404, oops,
page gone missing”. And so that’s it! We hosted our static website on Amazon S3. I hope you
enjoyed this video! Thanks for watching!

60 thoughts on Hosting a static website on Amazon S3 (AWS howto)

  1. Thank you for making it so easy. Love it.
    Question? Kindly please explain how can deploy a php based no-database site on AWS and how much it cost to host a static site on AWS /month?
    – Thanks a bunch for sharing your insights on AWS 🙂

  2. Error : "Policy has invalid resource ", is displayed on saving policy , please help me how to get valid resource

  3. It is easier and free to use Github as a host with no disadvantages, and if you want to automate it I have created a service that does everything from setting up a Hugo site, git init, GitHub pages configuration to cloning a theme and managing it all. Check out this video:

  4. would love to see a video showing connecting a domain name to your amazon s3 endpoint url with godaddy domain name 🙂

  5. In properties we have to choose ,enable web-hosting option, And need to provide our index & error page name in that so that it will work, which is not mentioned in the video

    Please correct me if my understanding is wrong here !!!


  7. I want to host a website like by only its own name no amazon or anything else in domain name i.e when user types, it should redirect it to the webpage, what should I do?

  8. I just wanted to say congratulations on making a really great tutorial. I love the way you walk through every step as if using AWS for the first time (like somebody watching this tutorial would) and then addressing errors as they come up naturally. Really great format for learning >>> I really appreciate you >>> I will definitely check out your other videos.

  9. Great video. The video in the following link will answer a lot of other commenters questions – click on the YouTube version in the video window.

  10. Hey, nice tutorial – aws can be very confusing because of it's millions of options. But now everyone can use it for static websites.

  11. i have a domain name and i want to host a static website on same with minimal traffic like 100 visits per month , is aws s3 a good option

  12. Thank you so much!!! I have a final due tomorrow and I couldn't figure this out at all. You made it so easy to understand!

  13. How would you update content after the website is created? I tried editing the index.html file and I still don't see my updates.

  14. very simply explained thanks. is it difficult to update html pages stored on s3?
    do s3 free tier supports high traffic?
    please answer

  15. Thanks for the video, greatly recommend people watching for creating your website. Again, happy thanks even though its been years ago. Great job!

  16. my website connects to Postgresql , is it static ? can it be hosted on s3.???
    I have made the website using Django, having used html, css, js, popper.

  17. This guide is outdated, the S3 creation user journey is changed, and blocks policy edition by default.
    That gave me a permission denied error that took me a while to debug.
    The solution was to uncheck all the public access settings boxes – then edit the policy – then block new edits in the public access settings again!

Leave a Reply

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