A serverless application uses a Lambda function and writes logs to CloudWatch Logs. A CloudFormation template creates the log group. The application needs to know the log group's name at runtime. How can the CloudFormation template be changed so the application can access the log group's name when it runs?
Choose an answer
Tap an option to check your answer.
Correct answer: Pass the log group's Amazon Resource Name (ARN) to the Lambda function as an environment variable..
Why this is the answer
Passing the log group's Amazon Resource Name (ARN) as an environment variable to the Lambda function is the correct and most common way to provide runtime configuration data to serverless applications. CloudFormation can easily retrieve the ARN of a created log group using intrinsic functions like Fn::GetAtt or Ref and then inject it into the Lambda function's environment variables section within the template. The Lambda function can then access this environment variable at runtime to know which log group to interact with. The other options are incorrect because: AWS::Include transform is for including snippets of CloudFormation templates, not for passing runtime data to applications. User data is primarily for EC2 instances to execute scripts at launch, not for Lambda functions. The Mappings section is for defining static lookup tables within a CloudFormation template, not for dynamically passing resource attributes to an application at runtime.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed