> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components/examples/nodejs-sdk-aws-lambda.md).

# Deploy Node.js SDK in AWS Lambda

Learn how to deploy Node.js SDK code to an AWS Lambda function.

This page provides information on how to deploy Node.js SDK code in AWS Lambda services.

## Before you begin

* Use similar Node.js SDK code as in the [JavaScript SDK example](https://github.com/Split-Community/Split-SDKs-Examples/blob/main/Javascript-SDK/README.md).
* AWS Lambda supports Node 10.x runtime (as of writing).
* Make sure your environment uses Node 10.x or compatible version.

## Step-by-step Guide

1. **Create your Node.js project**

   Add an `index.js` file with the following content. Replace the placeholders `SDK API KEY`, `USER ID`, and `SPLIT NAME` with your actual values:

   ```js
   const SplitFactory = require('@splitsoftware/splitio').SplitFactory;

   const factory = SplitFactory({
     core: {
       authorizationKey: 'SDK API KEY'
     },
     startup: {
       readyTimeout: 10
     },
     scheduler: {
       impressionsRefreshRate: 1,
       eventsPushRate: 2,
     },
     debug: true
   });

   exports.handler = async (event) => {
     const client = factory.client();
     try {
       await client.whenReady();
     } catch (error) {
       console.log("SDK_READY_TIMED_OUT event emitted. Treatments will be control");
     }

     const treatment = client.getTreatment("USER ID", "SPLIT NAME");
     console.log("\ntreatment: " + treatment);
     return treatment;
   };
   ```
2. **Install the SDK dependency**

   Run this command at your project root to install the Node.js SDK package:

   ```bash
   npm install --save @splitsoftware/splitio@10.16.0
   ```
3. **Prepare deployment package**

   Zip the `index.js` file and the `node_modules` folder into `function.zip`.
4. **Create your Lambda function**

   ![](https://1473625385-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrT2RGHAjtBTaObzchfpb%2Fuploads%2Fgit-blob-bf11289c15e671f19436315cc7173fcf897902d2%2Faws-1.png?alt=media)

   * Login to AWS Console
   * Go to **Lambda** → **Functions**
   * Click **Create function**
   * Choose **Author from scratch**
   * Select **Node.js 10.x** runtime
   * Give your function a name
   * Click **Create function**
5. **Configure Lambda function settings**

   ![](https://1473625385-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrT2RGHAjtBTaObzchfpb%2Fuploads%2Fgit-blob-fa9baebdeafe2a63fbf52d00aeb5e3f475920042%2Faws-2.png?alt=media)

   * Under **Basic settings**, set Memory (e.g., 256 MB)
   * Set Timeout (e.g., 1 minute)
6. **Upload your deployment package**

   Using the AWS CLI, upload your zipped package:

   ```bash
   aws lambda update-function-code --function-name YOUR_FUNCTION_NAME --zip-file fileb://function.zip
   ```
7. **Configure test event**

   ![](https://1473625385-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrT2RGHAjtBTaObzchfpb%2Fuploads%2Fgit-blob-3721b8766035f2a7cd163110f7f584df5d7b6333%2Faws-3.png?alt=media)

   * In the Lambda console, select **Configure test events**
   * Use the **Hello World** template
   * Provide necessary event key-value data (if needed)
   * Save the test event
8. **Test your Lambda function**

   ![](https://1473625385-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrT2RGHAjtBTaObzchfpb%2Fuploads%2Fgit-blob-2117bfa819836f623cd05604defccc2edd9c30ff%2Faws-4.png?alt=media)

   * Click **Test**
   * The expected output should be the treatment value
   * Logs will show any additional debug information

This example demonstrates how to run the Split Node.js SDK within AWS Lambda and retrieve feature flag treatments programmatically.

{% @harness-feedback/feedback %}
