What is the best design of a system that uploads a file to S3, than resizes it with lambda but using the same key as uploaded, without triggering the resize lambda function twice or more?
A possible solution to this problem is to use a S3 bucket event trigger to trigger the resizing Lambda function when a new file is uploaded to the S3 bucket. You can set the event to trigger the Lambda function only when a new object is created, not when it's modified. The Lambda function can then resize the file and store the resized version in the same S3 bucket using the same key as the original file, but with a different file format (e.g. adding _resized to the filename).

Additionally, you can add a check in the Lambda function to ensure it only resizes the file once. For example, you can store metadata in the object's metadata in S3 to indicate whether the file has been resized or not. Before resizing, the Lambda function can check this metadata and only resize the file if it hasn't been resized already.

By combining these two strategies, you can ensure that the Lambda function is triggered only once for each new file uploaded to the S3 bucket and that the resized version is stored in the same S3 bucket with the same key as the original file.