Building an AWS Serverless Web Application
--
Introduction
AWS serverless offerings results in great development experience, reduce management overhead and deployed applications can benefit from various out-of-the-box features such as high-availability, performance and cost optimization.
AWS Lambda, API Gateway, DynamoDB are example of great serverless offerings and we have previously discussed that how AWS SAM simplify the process of creating and deploying serverless applications.
Today, we’ll take those learning and put together a backend of a very simple web application. This exercise will help us to build a foundation which we can later extend for more advance requirements.
Now, I am assuming that you are already familiar with AWS serverless offering as we will not cover the basics. However, if you are new to the topics, please check the following posts for reference:
- AWS Serverless Applications using SAM -Basics
- AWS Serverless Applications using SAM — Part 2
- AWS Lambda Basics — Writing Serverless Code
What are We Building
Following screenshot shows the finished application, where a simple webpage (HTML, JavaScript, CSS) is making ajax calls on regular interval to an API backend to fetch the data (random quotes) and display it on webpage.
For this web frontend, we will be building a simple backend (NodeJS) consists of two lambda functions. We’ll have an AWS S3 bucket for file storage and we’ll also be using Amazon DynamoDB for data persistence.
Lets see these components one by one in the following sections.
Data Input
I have a json file (quotes.json) which contains quotes from different authors.
In our solution, we’ll have an S3 bucket (quote-json-data), where we/user will upload the json file.
Here is how the data looks like