Q5 — AWS DVA-C02 Ch.2
Question 5 of 100 | ← Chapter 2
A developer is building a serverless application that uses an AWS Lambda function. The developer will deploy the application using AWS CloudFormation. The application will log to Amazon CloudWatch Logs. The developer has already created a log group for the application in the CloudFormation template. The developer needs to modify the CloudFormation template to provide the log group name to the application at runtime. Which solution meets this requirement?
- A. Use the AWS::Include transform in CloudFormation to provide the log group name to the application.
- B. Pass the log group name to the application in the user data section of the CloudFormation template.
- C. Specify the log group name for the application using the Mappings section of the CloudFormation template.
- D. Pass the Amazon Resource Name (ARN) of the log group as an environment variable to the Lambda function. ✓
Correct Answer: D. Pass the Amazon Resource Name (ARN) of the log group as an environment variable to the Lambda function.
Explanation
Option D is the most appropriate solution. By passing the log group's ARN as an environment variable to the Lambda function, the application can access the log group name at runtime. This approach does not require using the AWS::Include transform, passing the log group name in user data, or using the Mappings section. 【Lantern Certification provided by: swufelp1999】