Deployment Integrations
On-premise Integrations
Platform Integrations

Integration Options

Using Layers
Without Layers
Serverless Framework
AWS SAM
AWS CDK
Using Layers

Using Layers

Integrating Thundra using AWS Lambda Layers is the recommended (and easier) way to get started with Thundra. Depending on whether or not you choose to use a custom runtime, you can integrate Thundra with no code changes at all or just by wrapping your handler function.

Step 1: Deploy Your Function to AWS Lambda

Bundle all your Node.js Lambda function files and any additional required packages, and then upload it to the AWS Lambda console using the “Upload a.zip file” option for the code entry type. Note that Thundra dependencies are not expected to be in the artifact to be uploaded, as they come with a layer that will be utilized at a later point.

Step 2: Configure Your Function

Add Thundra's Node.js layer to your Lambda function using the ARN below. Note that the ARN contains a region and a version parameter which you will need to set. Set the region value to your Lambda function's region and the version value to the layer version you want to use with your Lambda function.

arn:aws:lambda:${region}:269863060030:layer:thundra-lambda-node-layer-minified:${version}
Latest version of the Thundra Node.js layer

After the Thundra layer ARN has been added, you can continue using a custom runtime or continue without using a custom runtime. Regardless of what you choose, make sure to also set the thundra_apiKey environment variable to the API key you get from the Thundra console.

Step 3: Configure Handler

a. Auto wrap

Set the handler to thundra_handler.wrapper and then set the thundra_agent_lambda_handler environment variable value to your original handler (e.g., index.handler).

b. Manual wrap

You can wrap your Lambda handler to integrate Thundra as shown below.

index.js
const thundra = require("@thundra/core")();
exports.handler = thundra((event, context,callback) => {
callback(null, "Hello Thundra!");
});

In the example above, the required @thundra/core package is already available in Thundra's Node.js layer, which we already added. Thus, you don't need to install the package and bundle it with your Lambda function.

Step 4: Invoke Your Function

Now you can try to invoke your Lambda function and see the details of your invocation in the Thundra console!

Without Layers

Without Layers

If you do not want to use AWS Lambda Layers, you can still easily integrate Thundra to your Node.js Lambda function. All you have to do is install the @thundra/core package via npm.

Step 1: Install the @thundra/core package

npm install @thundra/core --save

Step 2: Wrap your Lambda Handler

After installing the @thundra/core module, you will need to wrap your Lambda handlers. Thundra will monitor your AWS Lambda function automatically, supporting callback along with various context functions.

handler.js
const thundra = require("@thundra/core")();
exports.handler = thundra((event, context,callback) => {
callback(null, "Hello Thundra!");
});

Step 3: Deploy Your Function to AWS Lambda

Bundle your function and any additional required Node.js packages, and then upload it to the AWS Lambda console using the “Upload a.zip file” option for the code entry type.

Step 4: Configure your function

In the AWS Lambda console, set the thundra_apiKey environment variable to the API key value you got from the Thundra console.

Step 5: Invoke your function!

Now you can try to invoke your Lambda function and see the details of your invocation in the Thundra console!

Serverless Framework

Serverless Framework

Step 1: Install Thundra’s Serverless Plugin to Automatically Wrap Your Functions

npm install serverless-plugin-thundra

Step 2: Adding Thundra's Serverless Plugin in serverless.yml File

After installing Thundra’s serverless plugin, specify it as a plugin for your serverless environment by adding it under the plugins section of your serverless.yml file.

serverless.yml
plugins:
- serverless-plugin-thundra

Step 3: Add thundra_apiKey to Environment Variables under Provider Section in serverless.yml

serverless.yml
provider:
environment:
thundra_apiKey: <YOUR THUNDRA API KEY>

Step 4: Deploy

serverless deploy

Step 5: Invoke your function!

Now you can try to invoke your Lambda function and see the details of your invocation in the Thundra console!

AWS SAM

AWS SAM

Step 1: Add configuration changes on SAM template.yml

  • Add the thundra_apiKey environment variable using your Thundra API key.

Globals:
Function:
Environment:
Variables:
thundra_apiKey: <your_api_key>
  • Add the Thundra layer to “Layers” in the Globals section. The ThundraAWSAccountNo and ThundraPythonLayerVersion parameters are defined in the Parameters section in the following configuration:

Latest version of the Thundra's Node.js layer:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraNodeLayerVersion:
Type: Number
Default: 24 # Or use any other version
Globals:
Function:
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-node-layer:${ThundraNodeLayerVersion}
  • Change Runtime of your functions to provided

Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: provided
Handler: handler.hello

An example configuration:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraNodeLayerVersion:
Type: Number
Default: 24 # Or use any other version
Globals:
Function:
Runtime: provided
Timeout: 5
Environment:
Variables:
thundra_apiKey: <your_api_key>
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-node-layer:${ThundraNodeLayerVersion}
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./
Handler: handler.hello

Step 2: Test / Deploy

To build and run your function locally, use the following:

sam build && sam local invoke

Then, package and deploy your function using sam.

Step 2: Invoke your function!

Now you can try to invoke your Lambda function and see the details of your invocation in the Thundra console!

AWS CDK

AWS CDK

Step 1: Apply Configuration Changes on Your Function Properties.

  • Add thundra_apiKey environment variable with your thundra API key.

import {Function} from "@aws-cdk/aws-lambda";
export class YourConstructClass extends core.Construct {
const thundraApiKey = <your_api_key>;
constructor(scope: core.Construct, id: string) {
const yourFunction = new Function(this, "YourHandler", {
..., // other function properties
environment: {
..., // other environment variables
thundra_apiKey: thundraApiKey
}
});
}
}
  • Define Thundra layer and add it to your function properties.

Latest version of the Thundra's Node.js layer:

import {Aws} from "@aws-cdk/core";
import {Function, LayerVersion} from "@aws-cdk/aws-lambda";
export class YourConstructClass extends core.Construct {
const thundraApiKey = <your_api_key>;
const thundraAWSAccountNo = 269863060030;
const thundraNodeLayerVersion = 48; // or any other version
const thundraLayer = LayerVersion.fromLayerVersionArn(
this,
"ThundraLayer",
`arn:aws:lambda:${Aws.REGION}:${thundraAWSAccountNo}:layer:thundra-lambda-node-layer:${thundraNodeLayerVersion}`
);
constructor(scope: core.Construct, id: string) {
const yourFunction = new Function(<scope>, <id>, {
..., // other function properties
environment: {
..., // other environment variables
thundra_apiKey: thundraApiKey
},
layers: [
thundraLayer,
... // other layers
]
});
}
}

Aws.REGION is a pseudo parameter which is bootstrapped from your stack's environment configuration

  • Change Runtime of your function to provided

import {Function, LayerVersion, Runtime} from "@aws-cdk/aws-lambda";
import {Aws} from "@aws-cdk/core";
import {Function, LayerVersion} from "@aws-cdk/aws-lambda";
export class YourConstructClass extends core.Construct {
const thundraApiKey = <your_api_key>;
const thundraAWSAccountNo = 269863060030;
const thundraNodeLayerVersion = 48; // or any other version
const thundraLayer = LayerVersion.fromLayerVersionArn(
this,
"ThundraLayer",
`arn:aws:lambda:${Aws.REGION}:${thundraAWSAccountNo}:layer:thundra-lambda-node-layer:${thundraNodeLayerVersion}`
);
constructor(scope: core.Construct, id: string) {
const yourFunction = new Function(this, "YourFunction", {
..., // other function properties
runtime: Runtime.PROVIDED,
environment: {
..., // other environment variables
thundra_apiKey: thundraApiKey
},
layers: [
thundraLayer,
... // other layers
]
});
}
}

An example configuration:

import {Aws} from "@aws-cdk/core";
import {Code, Function, Runtime, LayerVersion} from "@aws-cdk/aws-lambda";
export class YourConstructClass extends core.Construct {
const thundraApiKey = <your_api_key>;
const thundraAWSAccountNo = 269863060030;
const thundraNodeLayerVersion = 48; // or any other version
const thundraLayer = LayerVersion.fromLayerVersionArn(
this,
"ThundraLayer",
`arn:aws:lambda:${Aws.REGION}:${thundraAWSAccountNo}:layer:thundra-lambda-node-layer:${thundraNodeLayerVersion}`
);
constructor(scope: core.Construct, id: string) {
const handler = new Function(this, "MyFunction", {
runtime: Runtime.PROVIDED,
code: Code.asset("/path/to/your/resource"),
handler: "your.handler",
environment: {
thundra_apiKey: thundraApiKey
},
layers: [
thundraLayer
]
});
}
}

Step 2: Build / Deploy

npm run build && cdk deploy

Step 3: Invoke Your Function

Now you can try to invoke your Lambda function and see the details of your invocation in the Thundra console!