Deployment of Node.js application to AWS Lambda using Serverless


  • Awscli installed and configured on your system.
  • Serverless framework installed on system.
  • NodeJS & npm should be installated on system
  • Visual Studio Code

What is serverless ?

Serverless is a tool that helps build, deploy, and manage serverless applications.

What is Lambda ?

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

Some of the Serverless Framework features:

  • The Serverless Framework is an open-source tool for managing and deploying serverless functions. 
  • Serverless Framework is used for creating, deploying, managing and debugging the applications you created.
  • Supports multiple programming languages and cloud providers.
  • Good integration with CI/CD
  • Cloudformation support

Using a serverless.yml file you can create a service description. (defines your functions,events and resources)

# Step 1. Install serverless globally :

$ npm install serverless -g

We have successfully installed the serverless in our machine.

#Check the serverless version :

$ serverless -v

# Set AWS credentials we have to create user access and secret key

$ sls config credentials –provider aws –key PUBLIC_KEY –secret SECRET_KEY

#Create a folder called  serverless-nodejs-app  and go inside that folder

$ mkdir serverless-nodejs-app && cd serverless-nodejs-ap

# Create a serverless function, aws-node will set the runtime to Node.js

$ sls create -t aws-nodejs -n serverless-nodejs-app

# Install project dependencies

$ npm init -y

$ npm install –save

# Open project with visual studio code editor

$ sls deploy # Your function is deployed!

# invoke the serverless function

$ sls invoke -f hello -l