aws-samples/image-optimization

[Feature request] Supply original image from original S3 bucket

Opened this issue · 1 comments

In the current implementation lambda function makes copy of original image fromoriginalImageBucketName to transformedImageBucket with /original prefix. Which will increase storage usage and as fact will increase the cost, since original images usually have large size. Is there a way to avoid duplication of original image and supply it directly from original S3 bucket instead?

Hello,

The code can very easily changed to allow this way of working. In the code section where the image is uploaded to S3, check if the Key ends with /original, and only do the upload if the condition does not match.

However, It's a tradeoff. If you do that, you reduce the storage cost, however you add latency and cost for accessing original images on cache misses, because CloudFront will try with the generated image bucket, wont find the image, then fallback to the the Lambda, which will fetch the original image from your original S3 bucket then serve it.