Q67 — AWS DVA-C02 Ch.3
Question 67 of 100 | ← Chapter 3
A developer is implementing an AWS Lambda function that is invoked when objects are uploaded to Amazon S3. The developer wants to test the Lambda function locally on their development machine before deploying the function to a production AWS account. Which solution meets these requirements with the least operational overhead?
- A. Use the aws s3api put-object CLI command to upload an object to Amazon S3. Wait for the local Lambda invocation from the S3 event.
- B. Create a sample JSON file for a PutObject S3 event. Invoke the Lambda function locally using the aws lambda invoke CLI command, passing the JSON file and the Lambda function name as parameters.
- C. Use the sam local start-lambda CLI command to start Lambda locally. Use the sam local generate-event s3 put CLI command to create a Lambda test JSON file. Invoke the Lambda function using the sam local invoke CLI command, passing the JSON file as a parameter. ✓
- D. Create a JSON string for a PutObject S3 event. In the AWS Management Console, create a test event for the local Lambda function using the JSON string and execute the test.
Correct Answer: C. Use the sam local start-lambda CLI command to start Lambda locally. Use the sam local generate-event s3 put CLI command to create a Lambda test JSON file. Invoke the Lambda function using the sam local invoke CLI command, passing the JSON file as a parameter.
Explanation
Option C uses the SAM CLI tools to start a local Lambda runtime environment and generate a test JSON file for an S3 PutObject event using sam local generate-event s3 put. Then, it invokes the Lambda function locally using sam local invoke, enabling testing of Lambda behavior without deploying to AWS. Thus, Option C is the solution with the least operational overhead that satisfies the requirements. 【Lantern Certification: swufelp1999】