Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Build and Deploy Serverless webapplication on AWS using Lambda Function, API gateway and DynamoDB

Introduction

Lambda is the serverless computing solution provided by AWS. According to official AWS documentation,

“AWS Lambda is a compute service that lets you run code without provisioning or managing servers.”

Lambda follows the principles of serverless computing. In serverless computing, you don’t have to worry about server and operating system maintenance, capacity provisioning, automatic scaling, and logging.

AWS Lambda takes care of the provisioning of the underlying infrastructure. It ensures the code is run on a high-availability computing infrastructure and administers the solution. The developer only needs to provide the codebase in one of the languages supported by AWS Lambda.

Application Architecture

In this project, I created a serverless REST API that trigger a lambda function which generates a contact form and user can fill the form and save data to DynamoDB.

Create required IAM role

We will create an IAM role for AWS lambda function to call AWS services on your behalf.

Open AWS Management Console and search for IAM then click on create role.

click on AWS services this will allow lambda function to perform actions in this account.

In use case, select lambda function and click next

In Add permissions, add AWS lambdBasicexecutionRole and DynamoDB full access role

and add DynamoDB permission too and click on next

give name to the role you are creating. I am calling this role as lambdafunctionIAMrole. and click next. this will craete the IAM role needed for this project.

Create Lambda funtion

search for lambda in AWS management console then click on create function

give your function a name and select Python runtime for this project.

for executuon role please add lambdafunctionIAMrole to this function. and click on create functin.

create DynamoDB table

we need a DynamoDb to store data from our function.

Open AWS Managemnt console and search for DynamoDB. Click on create table.

give a table name. my table name is called serverlesstable. then write partition key. I will select partition key as email and type as string. leave all the settings as default.

Create a Rest API

we need to create an API gateway to trigger our Lambda function. click on Create API

Select RestAPI and click on Build

give API name as serverlessAPI and API endpoint as Regional and click on create API

click on create method

select method type as Any, lambda function as integration type and enable lambda proxy integration and select serverlessapp lambda function.

Package our lambda function

Open your lambda function by clicking on serverlessapp

upload the zip file to lambda function and click on API gateway endpoint.

Test the application

lets test our Application. we will click on API Gateway and that will trigger our lambda function and open our Contact form.

Now lets fill the form and see our data in DynamoDB table

Verify data in DynamoDB table

We can verify the data in DynamoDB table. open AWS management console and search for dynamodb table.

click on Explore Items

you can see Stuart's contact information in the table.

AWS Monitor and AWS X-ray

We can monitor our lambda function by checkng how many invocations, duration for our code to run, error and successrate of our application.

About

Built and deployed serverless web application

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors