Skip to content

eminw5/node-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Deploy a Node-Express App on AWS Lambda

The purpose of this repository is to demonstrate how to deploy a simple web application built by Express - Node.js web application framework on AWS Lambda.

Requirements

  • Node.js with Node Package Manager(npm) should be installed on your local system.

Architecture

Request Response Cycle :

aws-lambda-demo-with-node-express

Prepare the code

  • Download the sample_code directory to your local system.

  • Run npm install command in the same directory of the downladed folder. package.json file includes necessary dependencies to generate node_modules/

  • Create a zip file that will include all files in the directory.

Note: Don't zip the folder itself, but select all files individually. Refer to below image if needed:

example_zip

Create a Lambda function

  • Give your function a name like "aws-lambda-demo-with-node-express". Basic permissions will be sufficient for the purpose of this demonstration

  • Upload zip file created on previous step through the console and click DEPLOY

  • Rename your handler as "lambda.handler". It is the main module that uses aws-serverless-express package to easily get the event object Lambda receives from API Gateway

Integration with API Gateway

  • Create a new REST API and name it "aws-lambda-demo-with-node-express"

  • Create a method with ANY, use Lambda Proxy integration and select your function. Refer to below image if needed:

example_apigw_method

  • Create a resource, configure as proxy resource. Refer to below image if needed:

example_apigw_resource

  • Use Lambda Function Proxy and select your function.

  • Deploy your API and name the stage "calculator".

Note: This will be URL extension for our API, which needs to match with the html form inside our code.

<form class="" action="/calculator" method="post">

  • Now you can [Invoke URL] provided by Amazon API Gateway. You can find this on Stages column of the console.

invoke-url

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •