S3 high version count per object alerting

55 Views Asked by At

i'm looking for an option to alert me if there are more than n-Versions of any object in my S3 bucket.

This is meant to catch cases where lots of duplicate files are uploaded by accident which would be something i'd want to fix anyhow but would also cause unnecessary cost until my lifecycle policy kicks in and cleans up the non_current versions after 7 days.

I know that there is an option to delete non_current versions older than a certain number of newer versions but i would like to keep all created versions for the given timeframe of 7 days in case i need to restore the original file that was overwritten over and over again.

I first thought i could use Storage Lens to receive the metric of the number of versions per object. Sadly on closer inspection it seems like storage lens only supplies more general metrics such as the general number of versions. Not specific to any object.

My other two ideas for approaches were the following:

  • Use a lambda function that runs every time a new object is inserted and check for the number of versions for this object. This seems unnecessarily costly to me because i don't need this information instantly.

  • Run a script every day or so that uses the ListObjectVersions Request to find the current object versions and count them. I'm not really sure if this is cost effective either because the bucket contains about 5TB of data with around 35 million objects and im not too sure if this could lead to high costs for scanning and retrieving the object data.

I appreciate all suggestions for strategies or corrections on my assumptions for the stategies i've detailed above.

0

There are 0 best solutions below