2

We have an AWS Lambda (part of a broader AWS stack) that is configured using CloudFormation. It is being demanded that we implement/configure X-Ray on this Lambda. Company policy forbids us (on a role by role/account by account basis) from accessing the AWS console, which is part of why we're using CloudFormation to define our AWS stack; but it means we can't enable X-Ray through the AWS console (which is normally the way to do that).

Unfortunately, we haven't found documentation on using X-Ray with CloudFormation. Reviewing the CloudFormation Release History we see that X-Ray does not, indeed, appear to be listed. It seems CloudFormation does not support configuring Lambda with X-Ray in this way.

We also discovered something called TracingConfig, which can be enabled via CloudFormation. However, there isn't much documentation on what this does, or what the output looks like/where it goes. The hopeful tidbit of information we found relating to this is that documentation on both TracingConfig and X-Ray mentions in passing something they call "active tracing."

Thus, my question is ultimately, how much information can we get out of TracingConfig, and how close would that get us to the information that would otherwise be provided by X-Ray if we were able to use that?

or

Is there an undocumented way of enabling X-Ray in CloudFormation?

1 Answer 1

6

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

2
  • 3
    In case it's helpful, the setting to enable in a SAM template is Tracing: Active. Mar 30, 2018 at 18:25
  • Thanks, @BradyDowling. I was looking for this piece of information!
    – Hosam Aly
    May 16, 2018 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .