Publish your website without an application server on Amazon S3
In old times, deploying a Website usually meant to deploy to a web server that could host your “server code” (.Net, Java, PHP, Python, NodeJS, …). You needed a box (metal or virtual) that could execute that code through a web server (IIS, Apache, Tomcat, ExpressJS, … ) and have enough processing power to deal with the demand.
You might still need some backend processing for managing dynamic & shared data, but this can also be done in a ‘serverless’ approach (which will be covered in another article).
So, the challenge is to store your html, css & JS files in a place where they can be downloaded by the client browsers. This can be done with a simple Storage or File service. The one I like most is is Amazon S3 (Simple Storage Service), but I have also had great experiences in the past using Microsoft Azure Blob Storage and you can explore simple solutions based on other providers such as Dropbox, Github Pages, Google Firebase, …).
In S3 you can create a “bucket” (which is like a folder) where you can place your files and access them via http://….
For example (I am assuming that you already have an Amazon AWS account and you went to the S3 Service), I have created a new bucket called “thisisademo”:
<h1>Hi, this is a simple demo</h1>
<p>Your lucky number is <span id='luckyNumber'></span></>
const randomNumber = Math.floor( Math.random() * 100);
const targetElement = document.getElementById('luckyNumber');
targetElement.textContent = randomNumber;
You can upload it easily with AWS S3 console:
If you try to access the file right now you might get an “AccessDenied” error. To make it public double click on the file name in the console and choose “Make public”
And voilà … your webpage is published on the internet through this url:
In other articles I will cover:
- Publishing on S3 with your own domain name (e.g. http://demo.firstmakers.com/demo01/index.html)
- Use secure http connections (https) with your ow domain name
- Automatically deploying into S3 when you commit changes to a GitHub repository (this is cool!)
- User authentication without a server on the cloud
- Add Microservices / RESTFUL APIs running on the cloud
- Add data storage with cloud based NONSQL databases