My last post was discussing the S3 bucket which can be used as more than a simple dumb disk for storing family photos or videos.
One of the more interesting things that can be done with an S3 bucket is to use it as a web server.
Don’t get overly excited. Indeed S3 can be configured to perform as a web server but it is not a full fledged server that you might be used to. That is to say that it will serve up static content but not run server side scripts.
Once you have a S3 bucket setup it is trivial to create the static web site. Simply go into the properties for the bucket and enable “static website hosting” and provide the actual html script or scripts to be used.
However, just like in my previous article AWS – S3 buckets permissions are the tiny bug-a-boo that could cause some behavior problems in your website.
This simple example uses exactly one html page and two graphic files but because the permissions for one of the graphic files was not set to public the contents are not displayed when someone visits the web page. This is a common permission problem that needs to be kept in mind when creating static web pages on S3.
I am not a html programmer but I would suppose that the code (below) is virtually identical to what you might see in your normal website.
I would have loved to put the actual code here but was having formatting problems. The code is actually fairly simple html, if you are really curious you can download it here.
I am not expecting any problems with the Amazon S3 bucket but this web site does have one little flaw. If for some reason this S3 service was not available, it might be difficult to move it to another bucket to run. The reason for this is that the references to the various resources are using the actual path to the regional bucket (s3.us-east-2.amazonaws.com) and not something more generic like supercoolwebsite.com. However, this could probably be corrected by using route 53 and your own domain – it would still leave you to design a highly tolerant solution. You might want to replicate your files to another bucket in another region just in case.