Configuring X-Ray in Lambda with AWS CloudFormation vs TracingConfig
While not clear, TracingConfig
is the setting to enable AWS X-Ray.
TracingConfig is a property of the AWS::Lambda::Function resource that configures tracing settings for your AWS Lambda (Lambda) function. For more information about tracing Lambda functions, see Tracing Lambda-Based Applications with AWS X-Ray in the AWS Lambda Developer Guide. - AWS Lambda Function TracingConfig
You will also have to add the permission for xray:PutTraceSegments
and xray:PutTelemetryRecords
to your lambda's execution role.
Note: When I did this, I found I had to create a new execution role resource and move my policy inline, otherwise the CloudFormation ChangeSet would fail on creating the lambda as the role update wasn't fully propagated to all regions yet.
Take a look at a this blog post with more info: Enabling AWS X-Ray on AWS Lambda