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 option requires actual interaction with Amazon S3 to trigger the Lambda function, which means deploying to the cloud and not testing locally. It introduces operational overhead and is not efficient for local development.
While this method allows local invocation of the Lambda function using a JSON file, it doesn’t fully simulate the S3 event structure or environment. It may require additional adjustments to accurately reflect S3’s event payload.
This option utilizes AWS SAM (Serverless Application Model) to simulate the Lambda environment locally. It generates the appropriate S3 event structure and invokes the function with minimal setup, thus reducing operational overhead.
This approach involves using the AWS Management Console to create a test event, which does not align with local development. It also lacks the convenience of generating the event structure directly and testing locally without cloud resources.