nerdexam
Amazon

DVA-C02 · Question #370

A developer is implementing an AWS Lambda function that will be invoked when an object is uploaded to Amazon S3. The developer wants to test the Lambda function in a local development machine before p

The correct answer is C. Use the sam local start-lambda CLI command to start Lambda. Use the sam local generate-event. AWS SAM CLI provides built-in commands to both start a local Lambda endpoint and generate realistic S3 event payloads, enabling fully local testing with minimal setup overhead.

Submitted by kev92· Mar 5, 2026Development with AWS Services

Question

A developer is implementing an AWS Lambda function that will be invoked when an object is uploaded to Amazon S3. The developer wants to test the Lambda function in a local development machine before publishing the function to a production AWS account. Which solution will meet these requirements with the LEAST operational overhead?

Options

  • AUpload an object to Amazon S3 by using the aws s3api put-object CLI command. Wait for the
  • BCreate a sample JSON text file for a put object S3 event. Invoke the Lambda function locally. Use
  • CUse the sam local start-lambda CLI command to start Lambda. Use the sam local generate-event
  • DCreate a JSON string for the put object S3 event. In the AWS Management Console, use the

How the community answered

(57 responses)
  • A
    4% (2)
  • B
    16% (9)
  • C
    72% (41)
  • D
    9% (5)

Why each option

AWS SAM CLI provides built-in commands to both start a local Lambda endpoint and generate realistic S3 event payloads, enabling fully local testing with minimal setup overhead.

AUpload an object to Amazon S3 by using the aws s3api put-object CLI command. Wait for the

Using 'aws s3api put-object' requires an actual AWS account and S3 bucket, and depends on a real Lambda trigger being configured, which increases operational overhead and is not purely local.

BCreate a sample JSON text file for a put object S3 event. Invoke the Lambda function locally. Use

Manually creating a sample JSON event file works but requires the developer to know and replicate the exact S3 event schema, whereas SAM generates it automatically with less effort.

CUse the sam local start-lambda CLI command to start Lambda. Use the sam local generate-eventCorrect

The 'sam local start-lambda' command emulates the Lambda service locally, and 'sam local generate-event s3 put' automatically generates a correctly structured S3 PutObject event payload. Together they allow complete local invocation testing without touching an actual AWS account, providing the least operational overhead.

DCreate a JSON string for the put object S3 event. In the AWS Management Console, use the

Using the AWS Management Console requires publishing the Lambda function to AWS first, which contradicts the requirement to test locally before publishing.

Concept tested: Local Lambda testing with AWS SAM CLI

Source: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-invoke.html

Community Discussion

No community discussion yet for this question.

Full DVA-C02 Practice