feat(bucket): add lifecycle config to built-in bucket component
Hi guys,
initially i just thought about adding docs with an example (https://github.com/sst/sst/pull/6206) but after thinking some more I feel like this is such a common use case that it warrants first party support.
This PR adds just that.
In this basic version I expose expiration and filters, not the full blown pulumi lifecycle rules for simplicity and ease of configuration.
Happy to expand / iterate on everything if you think its required.
Cheers ✌️
This is code I've had to repeat over and over through multiple projects, so I'm really pumped this can be part of SST now.
note: if we merge this we should probably close #4941 and #6206
Agreed, at first i wanted a proper doc example but then decided to just add first party support. Hope we can get it merged soon once the SST team figures out the maintainer stuff.
@mkilp checking the API design you proposed and i'm wondering the following changes:
new sst.aws.Bucket("Example", {
lifecycle: [
prefix: "/tmp",
expiresIn: "7 days",
expiresAt: "2025-12-12",
]
});
the changes:
- array instead of an object for defining multiple rules
- rename
filterPrefixtoprefix - enabled is
trueby default - replace
expiresby top level properties: expiresInuses common SST syntax for defining duration (could also be passed as "12 months" using theduration.tsutility)expiresAtas top level propertyexpiredObjectDeleteMarkerremoved since people knowing what that is are probably going to need the Pulumi construct anyway
what do you think?
@mkilp checking the API design you proposed and i'm wondering the following changes:
new sst.aws.Bucket("Example", { lifecycle: [ prefix: "/tmp", expiresIn: "7 days", expiresAt: "2025-12-12", ] });the changes:
- array instead of an object for defining multiple rules
- rename
filterPrefixtoprefix- enabled is
trueby default- replace
expiresby top level properties:expiresInuses common SST syntax for defining duration (could also be passed as "12 months" using theduration.tsutility)expiresAtas top level propertyexpiredObjectDeleteMarkerremoved since people knowing what that is are probably going to need the Pulumi construct anywaywhat do you think?
@vimtor appreciate the feedback, I asked the exact same thing in the discord if there is a standard api. I really like your proposed changes, I'll get that in.
@vimtor just changed the api and made a new union type for the expiration. Hopefully we can get that in now that PRs are being merged!
one last thing, i'm maybe contradicting myself but i've noticed that the bucket already uses
filterPrefixandfilterSuffixfor the notifications:probably we should use those names and their description to stay consistent
Looking at pulumi AWS does not allow suffixes anymore, so I would be fine with staying with just "prefix"
@vimtor Comments are all set! Sorry, my VSCode PR review panel really messed with me today.
probably we should use those names and their description to stay consistent