Lambda active X-Ray tracing is not configured

Sample and trace requests for functions that need it.

Description

Active X-Ray tracing lets Lambda sample incoming requests and record trace data. PassThrough handles propagated trace context and is not equivalent to active tracing.

Potential impact

Missing trace data can make function latency and cross-service call problems harder to investigate.

Remediation

Set tracing_mode: Active when active tracing is needed, and grant the execution role the required X-Ray write permissions. Verify trace collection.

Examples

The examples change the tracing mode. Set lambda_runtime to a supported runtime compatible with the deployment package. Prepare the role and ZIP files separately.

Before

yaml
- name: Create Lambda functions in a loop
  community.aws.lambda:
    name: "{{ item.name }}"
    state: present
    zip_file: "{{ item.zip_file }}"
    runtime: "{{ lambda_runtime }}"
    role: "arn:aws:iam::987654321012:role/lambda_basic_execution"
    handler: "hello_python.my_handler"
    tracing_mode: "PassThrough"
    tags:
      key1: "value1"
  loop:
    - name: HelloWorld
      zip_file: hello-code.zip
    - name: ByeBye
      zip_file: bye-code.zip

After

yaml
- name: Create Lambda functions in a loop
  community.aws.lambda:
    name: "{{ item.name }}"
    state: present
    zip_file: "{{ item.zip_file }}"
    runtime: "{{ lambda_runtime }}"
    role: "arn:aws:iam::987654321012:role/lambda_basic_execution"
    handler: "hello_python.my_handler"
    tracing_mode: Active
    tags:
      key1: "value1"
  loop:
    - name: HelloWorld
      zip_file: hello-code.zip
    - name: ByeBye
      zip_file: bye-code.zip

References