You want to test an AWS Lambda function locally that will be triggered by an S3 object upload before deploying it to production. Which approach requires the least operational effort to achieve this?
Choose an answer
Tap an option to check your answer.
Correct answer: Start a local Lambda endpoint using sam local start-lambda. Generate an S3 put event JSON with sam local generate-event s3 put. Invoke the function locally with sam local invoke and the generated JSON..
Why this is the answer
The AWS Serverless Application Model (SAM) CLI offers robust local testing capabilities, making it the most efficient option here. sam local start-lambda creates a local endpoint, sam local generate-event s3 put quickly provides a realistic S3 event payload, and sam local invoke executes the function locally with that payload. This integrated workflow minimizes manual effort and accurately simulates the production environment. Using aws s3api put-object to trigger a local Lambda function isn't directly supported; S3 events trigger deployed Lambda functions. Manually creating a JSON file and using aws lambda invoke locally is possible but more cumbersome than SAM CLI, as you'd need to craft the event JSON yourself. The AWS Management Console is for testing deployed Lambda functions, not local ones.
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