Which solution will meet this requirement?
Use the AWS::Include transform in CloudFormation to provide the log group’s name to the application.
Pass the log group’s name to the application in the user data section of the CloudFormation template.
Use the CloudFormation template’s Mappings section to specify the log group’s name for the application.
Pass the log group’s Amazon Resource Name (ARN) as an environment variable to the Lambda function.
Explanations:
The AWS::Include transform is used to include snippets of other templates in the current template, not to pass parameters or values to applications. It does not provide a mechanism for passing the log group’s name to the Lambda function at runtime.
The user data section is primarily used for configuring EC2 instances at launch and is not applicable to AWS Lambda functions. Therefore, it cannot be used to pass the log group’s name to the Lambda function.
The Mappings section in a CloudFormation template is used to create key-value pairs for configuration purposes, but it does not provide a mechanism for passing values to applications at runtime. It is not suitable for making the log group’s name available to the Lambda function.
Passing the log group’s Amazon Resource Name (ARN) as an environment variable to the Lambda function is a valid method to provide runtime configuration. This allows the Lambda function to access the log group’s name directly during execution, meeting the requirement.