exam questions

Exam AWS Certified Developer - Associate DVA-C02 All Questions

View all questions & answers for the AWS Certified Developer - Associate DVA-C02 exam

Exam AWS Certified Developer - Associate DVA-C02 topic 1 question 287 discussion

A developer is creating a serverless application that uses an AWS Lambda function. The developer will use AWS CloudFormation to deploy the application. The application will write logs to Amazon CloudWatch Logs. The developer has created a log group in a CloudFormation template for the application to use. The developer needs to modify the CloudFormation template to make the name of the log group available to the application at runtime.

Which solution will meet this requirement?

  • A. Use the AWS::Include transform in CloudFormation to provide the log group's name to the application.
  • B. Pass the log group's name to the application in the user data section of the CloudFormation template.
  • C. Use the CloudFormation template's Mappings section to specify the log group's name for the application.
  • D. Pass the log group's Amazon Resource Name (ARN) as an environment variable to the Lambda function.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
albert_kuo
7 months ago
Selected Answer: D
Resources: MyLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-log-group" MyLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName: MyFunction Handler: index.handler Runtime: nodejs14.x Role: arn:aws:iam::123456789012:role/service-role/MyLambdaRole Environment: Variables: LOG_GROUP_ARN: !GetAtt MyLogGroup.Arn
upvoted 1 times
...
65703c1
11 months, 2 weeks ago
Selected Answer: D
D is the correct answer.
upvoted 2 times
...
Abdullah22
1 year, 1 month ago
Selected Answer: D
Explanation of why other options are less suitable: A. AWS::Include transform: While the AWS::Include transform allows importing values from other templates, it's generally used for larger configurations and not ideal for this specific purpose of passing a single value to the application. B. User data: The user data section in CloudFormation is typically used for one-time configuration scripts and not intended for passing sensitive information like log group names or ARNs, raising security concerns. C. CloudFormation Mappings: While mappings can store key-value pairs within the template, they are not directly accessible as environment variables within the application code.
upvoted 4 times
...
SerialiDr
1 year, 1 month ago
Selected Answer: D
By specifying the log group's ARN as an environment variable in the CloudFormation template for the Lambda function, the developer can easily access this information within the application code at runtime. This method provides a straightforward way to pass dynamic configuration or resource references to AWS Lambda functions without hardcoding values, thereby maintaining flexibility and ensuring that the application can utilize the correct resources after deployment.
upvoted 2 times
...
KarBiswa
1 year, 2 months ago
Selected Answer: D
Very nice question totally confusing. D is correct
upvoted 1 times
...
CrescentShared
1 year, 2 months ago
Selected Answer: D
User data is typically used to pass startup scripts to EC2 instances, not Lambda functions. This would not be the appropriate mechanism for a serverless application using Lambda. The Mappings section in a CloudFormation template is used to define sets of key-value pairs that can be used to specify conditional parameter values based on region or other criteria. It doesn't provide a direct way to make the log group's name available to the Lambda function at runtime.
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago