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, along with any additional required Python libraries and upload it to the AWS Lambda console using the 'Upload a.zip file' option for the code entry type option. Note that Thundra dependencies are not expected to be in the artifact to be uploaded as it comes with layer that will be mentioned at later steps.

Step 2: Configure your function

  • Add api key to the environment variables on Amazon Lambda Console

  • Add thundra layer

    Click on the Layers option on your Lambda function console in the Designer tab. Then select Add Layer button and add 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 part of the ARN is dynamic, so you need to change it according to the region where you deploy your function. So let say that you deploy your Lambda function to Oregon (us-west-2) region, and the layer version is 12. The layer ARN will be:arn:aws:lambda:us-west-2:269863060030:layer:thundra-lambda-python-layer:12

  • Configure handler

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

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

Clicking on the 'Test' button on the top right of the AWS console will result in an invocation of your function after you have configured test data as per the specifications of your function.

Step 4: Monitor your function with Thundra Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

Without Layers

Without Layers

Step 1: Install Thundra’s python package On the project directory run following command:

pip3 install thundra -t .

Step 2: Deploy your function to AWS Lambda Bundle all your Python module files, along with any additional required Python libraries and upload it to the AWS Lambda console using the 'Upload a.zip file' option for the code entry type option.

Step 3: Configure your function

  • Add api key to the environment variables on Amazon Lambda Console

  • Configure handler

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

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

Clicking on the 'Test' button on the top right of the AWS console will result in an invocation of your function after you have configured test data as per the specifications of your function.

Step 5: Monitor your function with Thundra Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you 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: Adding Thundra's Serverless Plugin in serverless.yml File After installing Thundra’s serverless plugin, please 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 thundra_apiKey to environment variables under provider section in serverless.yml

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

Step 5: Deploy & Test app

serverless deploy
serverless invoke --function functionName

Step 6: Monitor your function with Thundra

Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

AWS SAM

AWS SAM

Step 1: Add configuration changes on SAM template.yml

  • Add thundra_apiKey environment variable with your thundra api key.

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

Latest layer version of thundra python layer:

Parameters:
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 Handler of functions to be wrapped to thundra.handler.wrapper or set Handler in the Globals section if you want to wrap all of the functions in your SAM configuration file.

Globals:
Function:
...
Handler: thundra.handler.wrapper
  • For each function that is wrapped, add thundra_agent_lambda_handler environment variable with 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 application

To build & run your functions locally:

sam build && sam local invoke

Step 3: Monitor your function with Thundra

Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

AWS CDK

AWS CDK

Step 1: Apply configuration changes on your function properties.

  • Add 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 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 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 / Deploy

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!