Which solution will meet these requirements with the LEAST operational overhead?
Upload an object to Amazon S3 by using the aws s3api put-object CLI command. Wait for the local Lambda invocation from the S3 event.
Create a sample JSON text file for a put object S3 event. Invoke the Lambda function locally. Use the aws lambda invoke CLI command with the JSON file and Lambda function name as arguments.
Use the sam local start-lambda CLI command to start Lambda. Use the sam local generate-event s3 put CLI command to create the Lambda test JSON file. Use the sam local invoke CLI command with the JSON file as the argument to invoke the Lambda function.
Create a JSON string for the put object S3 event. In the AWS Management Console, use the JSON string to create a test event for the local Lambda function. Perform the test.
Explanations:
This approach relies on the actual upload of an object to S3, but the developer wants to test the Lambda locally. This would require deploying the function to AWS and cannot be done entirely on a local development machine.
This approach uses theaws lambda invokeCLI command, which is meant for invoking Lambda functions that are already deployed in AWS. It does not provide a solution for running the Lambda function locally.
This option uses AWS SAM (Serverless Application Model) to simulate the S3 event locally.sam local start-lambdaallows running Lambda functions in a local environment, andsam local invokeenables invocation with a generated event, making it the best solution for local testing with minimal overhead.
This option describes using the AWS Management Console to create a test event, but it does not meet the requirement to test the Lambda function locally. The AWS Management Console is used for testing in AWS, not for local testing.