Published on: Sat, 25 Jul, 2020
By: Amit Rai
Serverless is buzzword now a days. All cloud provider companies including AWS offers a well-architected platform to build and run application and services without thinking about servers. Since most of the companies are moving toward service oriented architecture so recently popular, FaaS (Function as a Service) framework allow developer to build and upload any application on cloud without even thinking about provisioning, managing, installing and scaling infrastructure. As per defination
"Serverless computing is a model where cloud provider manages the allocation and provisioning of infrastructure"
Serverless web application has its own benefits as compared to traditional one, as below
In this blog, we will go though a serverless web application architecture and we will see how can we build a serverless web application on AWS using managed services.
"Image from aws.amazon.com"
As depicted in architecture diagram application will use Amplify Console, Amazon Cognito, amazon API Gateway, AWS Lambda and Amazon DynamoDB.
Deploying static web content with Amplify Console
Amplify console will be integrated with your code repository in AWS CodeCommit or GitHub to continuous deploying application.
AWS Console > Amplify Console
AWS Amplify Console easy to use platform to deploy really complicated static websites following a continuous integration and delivery model. It can show you a preview of your application as it would rendor on different platforms.
Amazon Cognito User Pool for user authorization
AWS Console > Amazon Cognito
User pools is used to host and manage users and allow us to authenticate them and manage their user information. Application website can provide a sign-in form to allow register user to signin to Amazon Cognito.
Amazon Lambda and DynamoDB (Backend service)
Application backend will be build using Lambda function and DynamoDB. Request from browser (frontend) will be handled by Lambda function and record the data in DynamoDB
AWS Console > DynamoDB
Creating IAM Role for Lamda Function
There should be an IAM role associated with Lambda function. This role defines what other AWS services the function is allowed to interact with. For web application you can create an IAM role that grants your Lambda function permission to write logs to Amazon CloudWatch Logs and access to read and write to DynamoDB table.
Your backend code will be run in Lambda function in response to a HTTP request. Lambda function support most of the programming languages and platforms. You can choose any language to create backend logic. Later, Lambda function will be connected to API in order to create a fully functional backend for your web application.
AWS Console > Lambda
Lambda is a serverless FaaS (functions as a service) AWS platform that doesn't require managing servers to run any application. Function can be assigned a role and trigger point and then can interface with anything from databases, to any other services on the internet or internal VPC.
Amazon API Gateway
API Gateway is a fully managed AWS service to create, publish, maintain, monitor, and secure scalable APIs. The API can easily integrated with Cognito for authorization and Lambda function for backend to create completely serverless application.
AWS Console > API Gateway
After integration of API Gateway (RESTful API) with Lambda function that is created to run backend. You have to update the website to use the API endpoint so that frontend request can processed by lambda and information is saved in the DynamoDB table.
This was a very high level overview of AWS managed services those can be used building a serverless web application. A developer can leverage these services to build applications and can save a lot of time and money.