Add configurable S3 lifecycle rules for state bucket#6669
Add configurable S3 lifecycle rules for state bucket#6669FelixHeinstadt wants to merge 2 commits into
Conversation
Allow automatic cleanup of old objects in the SST state bucket via environment variables. Controlled by a master toggle (SST_LIFECYCLE=true) with per-prefix configuration for expiration days and noncurrent version retention (e.g. SST_LIFECYCLE_APP_DAYS, SST_LIFECYCLE_APP_VERSIONS).
|
thanks for your contribution @FelixHeinstadt this looks very promising i believe we should surface this as a top level config in export default $config({
app(input) {
return {
name: "my-sst-app",
home: "aws",
state: {
retention: 30, // documented as keep X number of versions
}
};
},
});i've collapsed everything into we'll also need to implement it for the cloudflare home provider. it should be doable since it's s3 compatible what do you think? do you want to give it a go? i can do the config part if you want to just leave one environment variable for the retention |
|
@vimtor If I saw it correctly only /app actually creates new object versions. The others unfortunately just create new objects, so only saying keep x versions would not help... |
|
@vimtor let me know your thoughts on how to proceed. |
|
sorry i need to learn more about this to give you a proper response my initial intution goes towards making everything a versioned object of finding a way to "when X state version is expired, delete all of the events, snapshots, updates, etc. before it" |
|
i'm merging some other state-related PRs. i'll get back to this soon. my current idea is that we should move to keeping all the state files as versioned files. i need to investigate this more, but i feel like it's worth doing anyway then we can just add a new |
|
While Specifically, would applying an S3 Asking because in our case, snapshot files dropped from ~2.4MB to ~210KB after enabling compress, but the noncurrent uncompressed versions remain and there's no clear interim path to reclaim that storage without risking state integrity. |
|
Hi @vimtor, following up on this — any updates on the versioned-files + In the meantime, I'd really appreciate some interim guidance on safely reclaiming storage in both buckets, since usage keeps growing on every deploy:
|
|
Superseded by #6925, which implements count-based state history retention across AWS, Cloudflare, and local homes. |
Problem: Over time the s3 storage usage exceeds multiple terabytes which causes increased costs and unnecessary storage usage. There should be an option to set sensible lifecycle rules for the sst state bucket.
Summary
SST_S3_LIFECYCLE=true(disabled by default)SST_S3_LIFECYCLE_{PREFIX}_DAYS) and noncurrent version retention (SST_S3_LIFECYCLE_{PREFIX}_VERSIONS)app/,lock/,eventlog/,snapshot/,update/prefixesUsage
Issues
Closes #6074
Closes #4521