A layer is an artifact that contains arbitrary code and data that can be referenced by zero, one, or more functions at the same time. During a function create or update time a layer is merged by the Lambda service with the function code. When a function is invoked the combined artifact (function and layer) is mounted onto Lambda’s execution environment making its contents available for the function execution. The content of the layer packages is extracted onto
/opt folder. Versioning of published layer is handled by AWS Lambda by giving monotonically increasing version number with every release. Resource-based policies can be assigned to layers to give them account based or public access.
Thundra Node Layer contains all Thundra NodeJS agent dependencies and Thundra Node Custom Runtime implementation files. Here is the directory structure for Thundra Node Layer:
|-- bootstrap # entry point for custom runtime, starts index.js |-- node | |-- index.js # Custom Runtime Implementation | |-- node # Node 8.10 binary, used by Custom Runtime | |-- node_modules # Contains Thundra NodeJS agent dependencies | |-- package-lock.json # Contains Thundra NodeJS agent build info | |-- package.json # Contains Thundra NodeJS agent build info
Custom Runtime feature in AWS Lambda which allows you to use any programming language to run your functions. By “Custom Runtime”, you provide your deployment package (typically .zip files) which contains
bootstrap file as an entry point where it can be an executable file such as a script or binary file. In here AWS Lambda platform is not interested in which programming language or runtime are you using, but just starts your bootstrap. It gives you more flexibility than managed runtimes but you need to implement the AWS Lambda “Runtime API” yourself. Thundra Node Layer includes a Custom Runtime Implementation which automatically wraps your AWS Lambda Handler Code with Thundra NodeJS Agent.
With Thundra Node Layer and Custom Runtime implementation, you can integrate your existing Lambda Functions with Thundra so easy without changing any of your code. The document shows configuration on a sample hello-world lambda function from a serverless repo. You can try Thundra Node Layer and Custom Runtime with any of your own deployed lambda functions.
- First, go to your AWS Lambda Function Page and Click
Layersin Designers tab
-Then Click Add Layer
Provide a layer version ARNand copy
arn:aws:lambda:<aws-region>:269863060030:layer:thundra-lambda-node-layer:<latest-version>the latest ARN of Thundra Node Layer and then click add. For this example, since we are using us-west-2 region, ARN value will be
arn:aws:lambda:us-west-2:269863060030:layer:thundra-lambda-node-layer:<latest-version>. Latest version of the layers can be seen here
- You should see Thundra Node Layer added as a layer to your Lambda Function now.
- Now, select
Use custom runtime in function code or layeras Lambda Runtime and update your handler with your handler. In our case, it is
index.handler. Then finally, enter your thundra api key as an environment variable.
- You integrated Thundra NodeJS Agent without changing any of your code. You can enjoy serverless monitoring.
The latest version of the layer is
You can add it to your project by copying the following line and changing the region.