Difference between Objects count and Metrics – Total number of objects in AWS S3

During the housekeeping on one of our clients accounts in AWS S3, I noticed that the bucket contains only two objects with the total size less than 10 MB:

However, when I go to Metrics, I saw that there is over 125 GB taken by over seven thousand objects:

Where is this discrepancy coming from? In my case, it is caused by incomplete multipart uploads. Sometimes such uploads are not finished properly by the application that started them, and this causes such remainings to stay as invisible objects.

How to get rid of old incomplete multipart uploads?

The simple way to get rid of such objects is to create a lifecycle policy that will remove them after a predefined number of days. In order to do this, go to your bucket, switch to Management tab and click “Create lifecycle rule”:

You can now name your rule, set it to apply to all objects in the bucket (and acknowledge that you know what it means). You should also check the checkmark next to “Delete expired object…” opiton:

In the next section, you should define the number of days after which incomplete downloads will be deleted, and click Save:

In my case, it was set to one day, because files are generated by the script, and either they are uploaded properly immediately, or the operation should be repeated. There is no need to keep them longer.

Once I will have a screenshot of results of this operation, I will post it here 🙂