exam questions

Exam AWS Certified Developer Associate All Questions

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

Exam AWS Certified Developer Associate topic 1 question 26 discussion

Exam question from Amazon's AWS Certified Developer Associate
Question #: 26
Topic #: 1
[All AWS Certified Developer Associate Questions]

A developer is writing an AWS Lambda function. The developer wants to log key events that occur during the Lambda function and include a unique identifier to associate the events with a specific function invocation.
Which of the following will help the developer accomplish this objective?

  • A. Obtain the request identifier from the Lambda context object. Architect the application to write logs to the console.
  • B. Obtain the request identifier from the Lambda event object. Architect the application to write logs to a file.
  • C. Obtain the request identifier from the Lambda event object. Architect the application to write logs to the console.
  • D. Obtain the request identifier from the Lambda context object. Architect the application to write logs to a file.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
rasiram
Highly Voted 3 years, 4 months ago
Answer A When Lambda runs your function, it passes a context object to the handler. This object provides methods and properties that provide information about the invocation, function, and execution environment. Context methods getRemainingTimeInMillis() – Returns the number of milliseconds left before the execution times out. Context properties functionName – The name of the Lambda function. functionVersion – The version of the function. invokedFunctionArn – The Amazon Resource Name (ARN) that's used to invoke the function. Indicates if the invoker specified a version number or alias. memoryLimitInMB – The amount of memory that's allocated for the function. awsRequestId – The identifier of the invocation request.
upvoted 35 times
...
RicardoD
Highly Voted 3 years, 3 months ago
A is the answer Each service that integrates with Lambda sends data to your function in JSON as an event. The structure of the event document is different for each event type, and contains data about the resource or request that triggered the function. Lambda runtimes convert the event into an object and pass it to your function.
upvoted 13 times
br00net
3 years, 3 months ago
An identifier that can be obtained from the Lambda context object is automatically included in the log message. As in the question developer wants - " to associate the events with a specific function invocation." We need to obtain another id: var apiRequestId = event.context['request-id'];
upvoted 4 times
ai_neuro
3 years, 3 months ago
It's A: The this identifier is not automatically included in the log message. I think you are referring to this post here: https://aws.amazon.com/blogs/compute/techniques-and-tools-for-better-serverless-api-logging-with-amazon-api-gateway-and-aws-lambda/ However, in this case the request-id is only found in the event structure because the blogger re-sends the API-gateway context information ($context.requestId) to the downstream lambda using a mapping template.
upvoted 3 times
CHRIS12722222
3 years ago
Your claim is not correct. Lambda request id is automatically included in the log message. This is exactly what is stated in the link you urself posted. C is correct https://aws.amazon.com/blogs/compute/techniques-and-tools-for-better-serverless-api-logging-with-amazon-api-gateway-and-aws-lambda/
upvoted 2 times
...
...
...
...
avinashk99
Most Recent 1 week, 1 day ago
Selected Answer: A
Each invocation of a Lambda function may run on a new container instance. The local file system (/tmp) is the only writable directory, but it: Is cleared out when the Lambda container is terminated or reused for another invocation.
upvoted 1 times
...
sumanshu
1 month, 3 weeks ago
Selected Answer: A
A) Correct - Each AWS Lambda invocation has a unique request identifier (aws_request_id) that can be obtained from the Lambda context object (context.aws_request_id). Logs written to the console are automatically captured and sent to Amazon CloudWatch Logs by the Lambda service. No additional file handling is required, ensuring simplicity.
upvoted 1 times
sumanshu
1 month, 3 weeks ago
B & C - Eliminated The event object contains the input payload for the Lambda function, not the unique request identifier.
upvoted 1 times
sumanshu
1 month, 3 weeks ago
D) Eliminated - writing logs to a file is inefficient and unnecessary in a Lambda environment.
upvoted 1 times
...
...
...
JonasKahnwald
2 months, 3 weeks ago
Selected Answer: A
Lambda event object doesn't provide unique identifier Writing logs to a file is not practical in a Lambda environment, as Lambda functions are stateless and ephemeral, meaning any files written to the local filesystem are not persistent.
upvoted 1 times
...
Selected Answer: A
AAAAAAAA
upvoted 1 times
...
AsmaZoheb
1 year ago
Selected Answer: A
i will go with A
upvoted 1 times
...
Quang_Nguyen
1 year, 1 month ago
Selected Answer: A
Answer A because: While Lambda supports writing logs to files, logging to the console offers distinct advantages: - Integration with CloudWatch Logs: Lambda automatically forwards console logs to CloudWatch Logs, providing centralized logging and monitoring. - Efficiency and Scalability: Lambda manages console logging, avoiding overhead and ensuring scalability. - Querying and Filtering: CloudWatch Logs allows you to query and filter logs based on the request identifier, making it easy to track events for specific invocations.
upvoted 2 times
...
a_win
1 year, 1 month ago
Selected Answer: D
considering the best practices for logging and persisting logs associated with Lambda function
upvoted 1 times
...
kyoharo
1 year, 2 months ago
Selected Answer: D
D. Obtain the request identifier from the Lambda context object. Architect the application to write logs to a file. Explanation: Lambda Context Object: The Lambda context object contains information about the invocation, including a unique identifier for the request. This identifier can be used to associate events with a specific function invocation. Write Logs to a File: Writing logs to a file is a common practice in Lambda functions, as it allows for persistent storage of logs that can be later analyzed. This is more suitable for production scenarios compared to writing logs to the console, which might not persist after the function execution.
upvoted 3 times
...
cdm2009
1 year, 4 months ago
Selected Answer: A
The default file options available to Lambda are temporary, and there's no mention of configuring any advanced storage system. Nor is it necessary - CloudWatch will just automatically collect output from Lambda STDOUT, providing optimal management and processing options inherently.
upvoted 2 times
...
sara_exam_topics
1 year, 4 months ago
Selected Answer: A
Obtaining Request Identifier from Lambda Context Object: The Lambda context object includes a unique request ID, which can be used to associate events with a specific function invocation. Writing Logs to the Console: Writing logs to the console (stdout) within a Lambda function is a common practice. These console logs can be captured and persisted using AWS CloudWatch Logs, making them accessible for later analysis and troubleshooting.
upvoted 2 times
...
CarlosC
1 year, 6 months ago
It's A, not D. writing logs to a file is not recommended for Lambda functions because the file system of a Lambda execution environment is ephemeral and not persisted across invocations.
upvoted 3 times
...
ancomedian
1 year, 6 months ago
Selected Answer: A
It is context that will add data to console or standard output, cause saving to file just adds overhead but output can anyways be seen or saved from cloudwatch if needed
upvoted 1 times
...
MalayShah
1 year, 7 months ago
Selected Answer: A
Both A & D seems correct. Actually D seems more relevant as it will contain only function logs which app is stroring instead of CloudWatch logs which contains Lambda default start execution logs as well. But still I want to go with A as storing to file in S3 will require additional IAM Role attached to Lambda execution role and question has just mention what will just work so.
upvoted 1 times
...
Yasser001
1 year, 7 months ago
Selected Answer: D
The correct answer is D. Obtain the request identifier from the Lambda context object. Architect the application to write logs to a file. AWS Lambda provides a context object that contains information about the runtime environment and the current function invocation. The context object includes a unique identifier called the "request identifier" or "request ID." This identifier can be obtained from the context object and used to associate the events with a specific function invocation. To accomplish the objective of logging key events with a unique identifier, the developer should obtain the request identifier from the Lambda context object. Additionally, the developer should architect the application to write logs to a file, rather than just writing them to the console. Writing logs to a file allows for better log management and enables additional analysis and processing of the logs. Therefore, option D is the correct choice: Obtain the request identifier from the Lambda context object and architect the application to write logs to a file.
upvoted 2 times
cdm2009
1 year, 4 months ago
The default file options available to Lambda are temporary, and there's no mention of configuring any advanced storage system. Nor is it necessary - CloudWatch will just automatically collect output from Lambda STDOUT, providing optimal management and processing options inherently.
upvoted 1 times
...
...
konatus
1 year, 7 months ago
Selected Answer: A
CloudWatch will collect the output from console.
upvoted 2 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