-
Note that
aws-xray-sdkis not a natively supported package in lambda. -
Let's create a layer in order to make
aws-xray-sdkimportable into our lambda function in python. -
Make sure we have conda installed, and put
source ~/anaconda3/etc/profile.d/conda.shin our
~/.bashrc, this is to make surecondais identifiable as a executable command.
-
Open an empty folder and
cdinto it -
pip install -t $(pwd) aws-xray-sdk
-
Create a new folder named
python, drag all package related files into it, and zip thatpythonfolder
-
Go to Layers and click
Create Layer
-
Upload the
zipfile and we are ready to go.
-
Test the import statement which originally throwed error without our additional layer:

import json from aws_xray_sdk.core import xray_recorder def lambda_handler(event, context): # TODO implement return { 'statusCode': 200, 'body': json.dumps('Hello from Lambda!') }








