Create a Lambda and modify and deploy it using cloud9 IDE, work with npm and add Node.js packages to Lambda – Beginner’s guide

In this tutorial, we will learn to
  1.  Create an AWS Lambda function with Node.js as the Runtime environment.
  2. Import the function into AWS Cloud9(Cloud9 IDE is an Online IDE).
  3. Initialize npm, add dependency moment.js and deploy it.


Step 1 – Create a Lambda.

Goto services->Lambda and click Create function

Choose Author from scratch, Node.js as Runtime, provide a function name and click Create function

The above code will be provided by default. By default, the aws-sdk is available in Lambda functions and you can import it using





Step 1 – Create an environment and  Import lambda into cloud9 IDE

Cloud9 is a AWS online IDE provided by AWS. To access cloud9 move to services->Cloud9.Click on the Create environment button, provide name and description, choose default options and click on the Create environment button.


The IDE interface will look like this.


To import the Lambda function, move to AWS resource and import your remote function.








Step3 – Install Node.js dependency, moment.js.

To install Node.js dependency, terminal access is required. To access terminal, go to window->New terminal and access your function folder using 

Do npm init and it will package.json file

Now install the moment.js dependency using

Upon installation completion, moment will be added to the the package.json dependencies and you will have a package-lock.json file.







step 4 – Deploying Lambda from Cloud9

To deploy the Lambda function, move to AWS resource and deploy your local function.

To check the update Lamda, move to services->Lambda, choose your Lambda function and it will have the updated files and code.

You can require  the moment module using

All the best with Lambda!!

Provide your suggestions and corrections in the comment box below.



No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *