Example Lambda Function running Python and X-ray using the https://github.com/racker/fleece/
- Run the following commands:
mkdir .vendor
pip install -r requirements.txt -t .vendor
serverless deploy
-
Got to the AWS Lambda Console and enable active tracing for the function.
-
Make sure your lambda function has permission to access GetUser in IAM and use X-Ray by creating a role with the following policy. If you use serverless framework to deploy, that step is not necessary since everything is set in the serverless.yml file
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogStream"
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"logs:PutLogEvents"
"iam:Get*"
],
"Resource": [
"*"
],
"Effect": "Allow"
}
]
}- Invoke your function and text X-Ray with Python
serverless invoke -f hello -l