How to remove a bucket with 400 million files on Amazon S3
Suppose you have accumulated several hundred million files in your bake (anything can happen) and you decide to delete them. You cannot delete a bake without deleting the contents. The deletion of the files themselves takes about 1000 in 2 seconds. It’s easy to calculate that 400 million files can be deleted for 9 days of the browser’s operation without shutting down, and you will have to pay for each operation (DELETE, though free, but LIST costs money).
But it is possible to configure the rules for storing files so that they are deleted automatically:
Log into the Amazon S3 Management Console.
Right click on the bucket and select Properties.
Expand the Livecycle block on the right side of the screen and click Add Rule.
In the Choose Rule Target window leave the Whole Bucket.
In the next Configure Rule window, select Permanently Delete Only and in the field that appears the number of days set 1 (unfortunately, 0 cannot be set).
And in the last Review window, click Create and activate rule.
Wait till tomorrow. Tomorrow the bucket should be empty.