AWS Certified Developer – Associate — Question 387
A developer is designing an AWS Lambda function to perform a maintenance activity. The developer will use Amazon EventBridge (Amazon CloudWatch Events) to invoke the function on an hourly schedule. The developer wants the function to log information at different levels of detail according to the value of a log level variable. The developer must design the function so that the log level can be set without requiring a change to the function code.
Which solution will meet these requirements?
Answer options
- A. Add a custom log level parameter for the Lambda function. Set the parameter by using the Lambda console
- B. Set the log level in a Lambda environment variable
- C. Set the log level in the Amazon CloudWatch Logs console.
- D. Add a custom log level parameter for the Lambda function. Set the parameter by using the AWS CLI.
Correct answer: B
Explanation
Using Lambda environment variables allows developers to pass dynamic configuration settings, such as log levels, to the function code without modifying the code itself. Options A and D are incorrect because AWS Lambda does not support 'custom parameters' as a native configuration feature outside of environment variables. Option C is incorrect because the Amazon CloudWatch Logs console is used for viewing log streams, not for dynamically altering the runtime configurations of a Lambda function.