Automatically placing a hold on google cloud storage objects after 24 hours

  Kiến thức lập trình

What is the best approach to placing a hold on an object in google cloud storage automatically after the file reaches a certain age? A default hold policy on a bucket would put a hold on right away, so that does not work. Google Cloud Storage Object Lifecycle Management does not apply to this because placing a hold is not one of the available actions for Object Lifecycle Management. Is a Cloud Function something that would be good for this kind of thing? If so, what would be a good strategy when using one to solve this need?

I looked in Object Lifecycle Management, which is able to perform actions based on the age of a stored object, but placing a hold on an object is not an available action. I would like this functionality to be automatic, and not based on any extra resources, like a managed vm, hence why I am hoping for some thoughts on if Google Cloud Function could be a good solution.

The two main ideas I have currently: run it once a day to filter on files in the bucket with no hold, check their age, and apply a hold if their age is over 24 hours. The “smarter” way, which I would prefer, is to have a cloud function trigger on object creation for that bucket and sleep for 24 hours? Or somehow schedule another function for 24 hours in the future?

New contributor

Eric Van Der Karr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.