S3 Versioning
I am using the Serverless Image Handler, which utilizes a CloudFront distribution to cache images. My origin S3 buckets have versioning enabled. However, I have encountered an issue where CloudFront does not respect the versionId query parameter and always retrieves the latest version of an image. Or maybe CloudFront respect that but Lambda does not?
I have taken the step of configuring CloudFront to pass the versionId query parameter, but unfortunately, it does not seem to be working as expected. I'm unsure of what I might be missing or if there is something else I need to consider. Could you please provide some guidance or suggestions on how to address this issue?
@barth12 Serverless Image Handler does not currently support the ability to manage versions of the original image. We will add this to the backlog to review if support might be added.
Hi @barth12, This isn't something we currently plan to implement. However, if you'd like to implement it yourself, the following is what I would expect would need to be changed:
- queryStringBehaviour would need to allow the
versionquery parameter for both cache and originRequestPolicy. Location - The ImageHandlerEvent queryStringParameters interface should include
version. Location - You'd have to extract the version query parameter out of the request in the setup method
- That value would need to be passed into the
getOriginalImagecall.
- That value would need to be passed into the
- In the
getOriginalImagecall, include theVersionIdparameter in the imageLocation object used to make the request. Location- It's worth noting that the backend lambda would require the
s3:GetObjectVersionpermission for that object, though that is included by default in the current version of SIH.
- It's worth noting that the backend lambda would require the
Let me know if that ends up working for you, Simon