Deployment Integrations
On-premise Integrations
Platform Integrations

Integration Options

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

Using Layers

Step 1: Deploy Your Function to AWS Lambda

Bundle all your Python module files and any additional required Python libraries, 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 the API key to the environment variables on the Amazon Lambda console.

Add Thundra layer

Next, add the Thundra layer by clicking on the Layers option in the Designer tab on your Lambda function console. Then select the “Add Layer” button and add the Thundra layer's ARN.

arn:aws:lambda:${region}:269863060030:layer:thundra-lambda-python-layer:${latest-version}
Latest layer version of thundra python layer

Note that the region of the ARN is dynamic, so you need to change it accordingly to the region where you deploy your function. So let’s say that you deploy your Lambda function to the Oregon (us-west-2) region. The layer ARN will be:arn:aws:lambda:us-west-2:269863060030:layer:thundra-lambda-python-layer:${layer-version}

Configure handler

Set the handler to thundra.handler.wrapper. Set the thundra_agent_lambda_handler environment variable value to your original handler (e.g., handler.handle).

Step 3: Invoke your deployed function by clicking on the Test button on the top right

Clicking on the “Test” button, which is located on the top right side of the AWS console, will result in an invocation of your function (after you have configured test data per the specifications of your function).

Step 4: Monitor your function with Thundra After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.

Without Layers

Without Layers

Step 1: Install Thundra’s python package

In the project directory, run the following command:

pip3 install thundra -t .

Step 2: Deploy Your Function to AWS Lambda.

Bundle all your Python module files and any additional required Python libraries, and then upload it to the AWS Lambda console using the “Upload a.zip file” option for the code entry type.

Step 3: Configure Your Function

Add the API key to the environment variables on the Amazon Lambda console.

Configure Handler

Set the handler to thundra.handler.wrapper. Set the thundra_agent_lambda_handler environment variable value to your handler.

Step 4: Invoke Your Deployed Function

Clicking on the “Test” button, which is located on the top right side of the AWS console, will result in an invocation of your function (after you have configured test data per the specifications of your function).

Step 5: Monitor Your Function with Thundra

After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.

Serverless Framework

Serverless Framework

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

npm install serverless-plugin-thundra

Step 2: Add 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 component to custom

Add the thundra component under custom with apiKey under that, as seen below:

serverless.yml
custom:
thundra:
apiKey: <YOUR THUNDRA API KEY>

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

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

Step 5: Deploy and Test app

serverless deploy
serverless invoke --function functionName

Step 6: Monitor Your Function with Thundra

After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.

AWS SAM

AWS SAM

Step 1: Add Configuration Changes on the SAM template.yml

  • Add the thundra_apiKey environment variable along with 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 layer version of thundra python layer:

ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraPythonLayerVersion:
Type: Number
Default: 12 # Or use any other version
Globals:
...
Function:
...
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-python-layer:${ThundraPythonLayerVersion}
  • Change the handler of functions to be wrapped to thundra.handler.wrapper. Alternatively, if you want to wrap all the functions in your SAM configuration file, you can set the handler in the Globals section.

Globals:
Function:
...
Handler: thundra.handler.wrapper
  • For each wrapped function, add the thundra_agent_lambda_handler environment variable with the value set to the handler path of your function.

Resources:
HelloWorldFunction1:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: hello_world_1.app.lambda_handler

An example configuration:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraPythonLayerVersion:
Type: Number
Default: 11 # Or use any other version
Globals:
Function:
Runtime: python3.7
Timeout: 5
Handler: thundra.handler.wrapper
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-python-layer:${ThundraPythonLayerVersion}
Environment:
Variables:
thundra_apiKey: <your_api_key>
Resources:
HelloWorldFunction1:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: hello_world_1.app.lambda_handler

Step 2: Test the Application

To build and run your functions locally:

sam build && sam local invoke

Step 3: Monitor Your Function with Thundra

After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.

AWS CDK

AWS CDK

Step 1: Apply Configuration Changes to Your Function Properties

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

from aws_cdk import (core,
aws_lambda as lambda_)
class YourConstructClass(core.Construct):
def __init__(self, scope: core.Construct, id: str):
super().__init__(scope, id)
thundraApiKey = <your_api_key>
handler = lambda_.Function(self, "YourHandler",
..., # other function properties
environment=dict(
..., # other environment variables
thundra_apiKey=thundraApiKey)
  • Define the Thundra layer and add it to your function properties.

Latest layer version of thundra python layer:

from aws_cdk import (core,
aws_lambda as lambda_)
class YourConstructClass(core.Construct):
def __init__(self, scope: core.Construct, id: str):
super().__init__(scope, id)
thundraApiKey = <your_api_key>
thundraAWSAccountNo = 269863060030
thundraPythonLayerVersion = 31 # or any other version
thundraPythonLayer = lambda_.LayerVersion.from_layer_version_arn(self, "ThundraLayer",
"arn:aws:lambda:{}:{}:layer:thundra-lambda-python-layer:{}".format(
core.Aws.REGION, thundraAWSAccountNo, thundraPythonLayerVersion)),
handler = lambda_.Function(self, "YourHandler",
..., # other function properties
environment=dict(
..., # other environment variables
thundra_apiKey=thundraApiKey),
layers=[
thundraPythonLayer,
... # other layers
]
)

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

  • Change the handler of your function to thundra.handler.wrapper, and add the environment variable thundra_agent_lambda_handler with your handler.

from aws_cdk import (core,
aws_lambda as lambda_)
class YourConstructClass(core.Construct):
def __init__(self, scope: core.Construct, id: str):
super().__init__(scope, id)
thundraApiKey = <your_api_key>
thundraAWSAccountNo = 269863060030
thundraPythonLayerVersion = 31 # or any other version
thundraPythonLayer = lambda_.LayerVersion.from_layer_version_arn(self, "ThundraLayer",
"arn:aws:lambda:{}:{}:layer:thundra-lambda-python-layer:{}".format(
core.Aws.REGION, thundraAWSAccountNo, thundraPythonLayerVersion)),
handler = lambda_.Function(self, "YourHandler",
..., # other function properties
handler=thundra.handler.wrapper
environment=dict(
..., # other environment variables
thundra_apiKey=thundraApiKey,
thundra_agent_lambda_handler=<your_handler>),
layers=[
thundraPythonLayer,
... # other layers
]
)

An example configuration:

from aws_cdk import (core,
aws_lambda as lambda_)
class YourConstructClass(core.Construct):
def __init__(self, scope: core.Construct, id: str):
super().__init__(scope, id)
thundraApiKey = <your_api_key>
thundraAWSAccountNo = 269863060030
thundraPythonLayerVersion = 31
thundraPythonLayer = lambda_.LayerVersion.from_layer_version_arn(self, "ThundraLayer",
"arn:aws:lambda:{}:{}:layer:thundra-lambda-python-layer:{}".format(
core.Aws.REGION, thundraAWSAccountNo,
thundraPythonLayerVersion))
with open("your-lambda-handler.py", encoding="utf8") as fp:
handler_code = fp.read()
handler = lambda_.Function(self, "YourHandler",
runtime=lambda_.Runtime.PYTHON_3_8,
code=lambda_.InlineCode(handler_code),
handler="thundra.handler.wrapper",
environment=dict(
thundra_apiKey2=thundraApiKey,
thundra_agent_lambda_handler="your.handler"),
layers=[
thundraPythonLayer]
)

Step 2: Build and Deploy

cdk deploy

Step 3: Invoke Your Function!

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