

It’s not interesting in its own right, but it serves to show that the SDK has been installed. We’ll create a trivial test.js file that uses the AWS SDK to print some EC2 config data. Next we’ll run nodejs locally to make sure we have a valid configuration before proceeding. $ npm install -prefix=~/lambdaTestFunction node_modules/aws-sdkĪt this point we’ve installed the ‘aws-sdk’ module into the node_modules directory of our lambdaTestFunction folder. This is just for illustration the current version of the AWS SDK is pre-installed in Lambda, but you could use this technique to load other pre-built JavaScript packages or if you actually needed an earlier version of the AWS SDK for compatibility reasons. $ cd lambdaTestFunction Step 2: Install an npm packageįor this example, we’ll keep things simple and install the AWS SDK. Step1: Create a new directory to hold your Lambda function and its modules. We’ll start by including prebuilt modules then move on to native ones. Using npm packages and custom modules/packages with Lambda is easy. Using Existing JavaScript Packages with Lambda

To do the steps below, you’ll need an EC2 instance or a similar machine running Amazon Linux with nodejs installed.

In this post we take a look at how to use custom nodejs packages with AWS Lambda, including building and packaging native nodejs modules for use in your Lambda functions.
