Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active June 6, 2025 13:46
Show Gist options
  • Save yuvalif/8f27ebcdcd118264652bfdb96217d95e to your computer and use it in GitHub Desktop.
Save yuvalif/8f27ebcdcd118264652bfdb96217d95e to your computer and use it in GitHub Desktop.
-- Lua script to auto-tier S3 object PUT requests
-- based on this: https://ceph.io/en/news/blog/2024/auto-tiering-ceph-object-storage-part-2/
-- exit script quickly if it is not a PUT request
if Request == nil or Request.RGWOp ~= "put_obj" then
return
end
local threshold = 1024*1024 -- 1MB
local debug = true
-- apply StorageClass only if user hasn't already assigned a storage-class
if Request.HTTP.StorageClass == nil or Request.HTTP.StorageClass == '' then
if Request.ContentLength < threshold then
Request.HTTP.StorageClass = "SMALL_OBJ"
else
Request.HTTP.StorageClass = "STANDARD"
end
if debug then
RGWDebugLog("applied '" .. Request.HTTP.StorageClass .. "' to object '" .. Request.Object.Name .. "'")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment