I’ve been trying for a few days to set up versioning on AWS S3.
Setting up the versioning itself was simple, but I would like to avoid versioning my objects forever.
I saw that this required the use of LifecycleHooks. Except that they only run once a day, and I can’t run them manually, which makes iterations slow.
What I would like to do is:
- Version all objects, and keep the versions, including potential deletion markers, for 15 days.
- Except the objects which starts by health-* that I don’t want to version (if not possible, only keep versions during 1 day), and I don’t want to keep deletion markers either.
Moreover, my objects are stored with a path per client (/client/app/myFile, /client/app/health-xxx). I don’t know if it has an impact on the rules prefix?
I tried by myself, with the help of this documentation, but I experiment difficulties to translate my high level business need to concrete rules. And like I said, since I can iterate only once a day, it’s quite slow ^^’
2
Answers
Thanks @Budaker for the quick response, which aswer a some questions I had, and gives useful informations! :)
Let me reformulate (and updating it accordingly to the fact I can't avoid versionning for the prefixed object /client/app/health- ).
General Case :
Exception Case : For any files prefixed by /client/app/health-
Considering your example and explaination, you gave me a sample for the general case. I don't see how I could cover the exception case tho. But you gave me enough material to be able to find a solution on my own :)
I will edit this message with the full solution in a few days - After testing it to be sure it works.
First things first, you can’t have versioning enabled for some objects and exclude other. Either you have it, or you don’t.
Also, keep in mind that:
Having said that, you might actually need more than one rule, but I’m not sure, as your use case is not clear.
Anyhow, when working with more than one rule per bucket, remember that:
Permanent deletion takes precedence over transition.
Transition takes precedence over creation of delete markers.
So, summing it up, you might use something like this:
Apply it with:
As for since I can iterate only once a day, it’s quite slow, well, you can’t speed it up on the S3 end, so you might consider creating a Lambda function that basically deletes the objects you don’t need.
You can run the function as often as you want / need.