Answer - C.
The AWS Documentation mentions the following.
Setting Up AWS X-Ray with Lambda.
Following, you can find detailed information on how to set up an X-Ray with Lambda.
Before You Begin.
To enable tracing on your Lambda function using the Lambda CLI, you must first add tracing permissions to your function's execution role.
To do so, take the following steps.
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
Find the execution role for your Lambda function.
Attach the following managed policy: AWSXrayWriteOnlyAccess.
Option A is incorrect since this is used if you need to use an X-Ray with an application that is hosted on an EC2 Instance.
Option B is incorrect since this is not required to begin using the X-Ray service with AWS Lambda.
Option D is incorrect since the permissions need to be assigned the other way around.
For more information on enabling X-Ray with AWS Lambda, please refer to the below URL-
https://docs.aws.amazon.com/lambda/latest/dg/enabling-x-ray.html
AWS X-Ray is a service that helps developers to analyze and debug distributed applications such as those running on AWS Lambda. With X-Ray, developers can trace requests made to their application and visualize the service map of their application components, helping to identify performance bottlenecks and issues.
To use AWS X-Ray with your Lambda function, you need to ensure that the following steps are taken:
Ensure that the X-Ray SDK is installed in your Lambda function code: To use X-Ray, you need to have the X-Ray SDK installed in your Lambda function code. The X-Ray SDK provides a set of libraries and tools that help you to instrument your code, so that X-Ray can trace requests and analyze performance data.
Ensure that the Lambda function is registered with X-Ray: Once you have the X-Ray SDK installed in your code, you need to ensure that your Lambda function is registered with X-Ray. This can be done either through the AWS Management Console or through the AWS CLI. When you register your function, AWS X-Ray automatically starts tracing requests to your Lambda function.
Ensure that the IAM Role assigned to the Lambda function has access to the X-Ray service: To enable X-Ray tracing, you need to ensure that the IAM Role assigned to the Lambda function has permissions to write trace data to the X-Ray service. This can be done by attaching the appropriate policy to the IAM Role.
Therefore, the correct answer to the question is B. Ensure that the Lambda function is registered with X-Ray. Although the other options are also important for enabling X-Ray tracing, they are not essential to ensure that X-Ray can be used with your Lambda function. The X-Ray daemon process is not required when using X-Ray with Lambda functions. The IAM Role assigned to the Lambda function needs to have access to the X-Ray service, but this can be achieved by attaching the appropriate policy to the role. The IAM Role assigned to the X-Ray function is not relevant to this question.