Question #556
A company’s developer needs to activate Amazon CloudWatch Logs Insights for an application’s AWS Lambda functions. The company uses an AWS Serverless Application Model (AWS SAM) template to deploy the application. The SAM template includes a logical resource that is named CloudWatchLogGroup.
How should the developer modify the SAM template to activate CloudWatch Logs Insights for the Lambda functions?
Add an output named CloudWatchInsightRule that contains a value of the Amazon Resource Name (ARN) for the CloudWatchLogGroup resource.
Add a parameter named CloudWatchLogGroupNamePrefix that contains a value of the application name. Reference the new parameter in the CloudWatchLogGroup resource.
For each Lambda function, add the layer for the Lambda Insights extension and the CloudWatchLambdaInsightsExecutionRolePolicy AWS managed policy.
For each Lambda function, set Tracing mode to Active and add the CloudWatchLambdaInsightsExecutionRolePolicy AWS managed policy.
Explanation
The correct answer is C. To activate CloudWatch Logs Insights for a Lambda function, you need to ensure that the Lambda function has access to the necessary CloudWatch features. This involves attaching the AWS managed policy called CloudWatchLambdaInsightsExecutionRolePolicy
, which grants permissions for logging and insights, and adding the Lambda Insights extension as a layer to the function.
Option A is incorrect because just generating an output ARN does not actually activate Insights; it merely provides information.
Option B doesn't address the requirement to modify the function itself to incorporate data insights. Simply adding a parameter won't enable CloudWatch Logs Insights.
Option D, while it correctly suggests enabling tracing, doesn't mention the need for the Lambda Insights layer and offers partial functionality without the complete requirements needed for activation.
Key concepts to remember:
1. AWS Lambda Insights requires both the Lambda Insights extension and the appropriate permissions (via a managed policy) to be configured for proper operation.
2. Output parameters or naming conventions alone do not affect the activation of specific AWS services or features.
Answer
The correct answer is: C