Answers: <p>This looks like it was added to Terraform back in May 2017, you enable it with the <code>tracing_config</code> block:</p>
  
  <pre><code>tracing_config {
    mode = "Active"
  }
  </code></pre>
  
  <p>You will also need to make sure that Terraform has a minimum of Write access to X-ray to enable the above to work:</p>
  
  <pre><code>data "aws_iam_policy" "aws_xray_write_only_access" {
    arn = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-23T14:48:30.613Z
Answers: 2019-10-23T14:48:30.613Z
Answers: Richard Slater
Body: <p>On the console, there’s the option to enable active tracking for X-ray tracking but I can see this in the Terraform <a href="https://www.terraform.io/docs/providers/aws/r/lambda_function.html" rel="nofollow noreferrer"><code>aws_lambda_function</code></a> resource the <a href="https://www.terraform.io/docs/providers/aws/r/xray_sampling_rule.html" rel="nofollow noreferrer"><code>aws_xray_sampling_rule</code></a> resources?</p>
  
  <p>I'm currently manually enabling it in the console to enable me to test it but I'd like to enable it through Terraform when I build the Lambda?</p>
  
Tags: <amazon-web-services><terraform><aws-lambda>
Title: How can I enable active tracing by default for an AWS Lambda function using Terraform?
UserDisplayName: doug
ThreadText: # How can I enable active tracing by default for an AWS Lambda function using Terraform?
  
  (Asked by: username_0 on 2019-10-23)
  
  On the console, there’s the option to enable active tracking for X-ray tracking but I can see this in the Terraform [`aws_lambda_function`](https://www.terraform.io/docs/providers/aws/r/lambda_function.html) resource the [`aws_xray_sampling_rule`](https://www.terraform.io/docs/providers/aws/r/xray_sampling_rule.html) resources?
  
  I'm currently manually enabling it in the console to enable me to test it but I'd like to enable it through Terraform when I build the Lambda?
  
  **Tags:** amazon-web-services, terraform, aws-lambda
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-23. Score: 2
  
  This looks like it was added to Terraform back in May 2017, you enable it with the `tracing_config` block:
  
  ```
  tracing_config {
    mode = "Active"
  }
  
  ```
  
  You will also need to make sure that Terraform has a minimum of Write access to X-ray to enable the above to work:
  
  ```
  data "aws_iam_policy" "aws_xray_write_only_access" {
    arn = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
  }
  
  ```
  
  
  ---
  
  