简体   繁体   English

从 S3 IA 中删除 20 亿个对象的最便宜方法

[英]Cheapest way to delete 2 billion objects from S3 IA

I have a bucket in S3 (Infrequent access) containing 2 billion objects.我在 S3(不经常访问)中有一个包含 20 亿个对象的存储桶。 It is too big to delete in the console or over the api without taking years.在控制台中或通过 api 删除而无需花费数年时间,它太大了。

I can create a lifecycle rule to expire and delete the objects but the calculator predicts this will cost me > $20,000 .我可以创建一个生命周期规则来过期和删除对象,但计算器预测这将花费我 > $20,000 Is that correct?那是对的吗? Is there a better way to delete a bucket?有没有更好的方法来删除存储桶?

I have a file effectively containing a list of all the objects in that bucket if that helps.如果有帮助,我有一个文件有效地包含该存储桶中所有对象的列表。

Update 2021: 2021 年更新:

An answer below from @MAP points out that there is now an "Empty" button.下面来自@MAP 的回答指出现在有一个“空”按钮。 I haven't tested yet, but looks like the way to go (I'll accept that answer once tested):我还没有测试过,但看起来像是要走的路(测试后我会接受这个答案):

空按钮截图

If you have a list of all the objects available then you can certainly use Multi Delete Object action.如果您有所有可用对象的列表,那么您当然可以使用多删除对象操作。 Apparently this API is free .显然这个API 是免费的 I would create AWS Step Functions state machine to loop through the file and delete 1000 objects at a time.我会创建AWS Step Functions 状态机来遍历文件并一次删除 1000 个对象。 1000 appears to be the limit. 1000 似乎是极限。

It will take around 2M step function transactions to delete all the objects in the bucket.删除存储桶中的所有对象大约需要 200 万步函数事务。 As per the pricing for step function it will cost you around $50 + cost of Lambda invocations around $1 so total cost roughly $51.根据 step 函数的定价,您将花费大约 50 美元 + 大约 1 美元的 Lambda 调用成本,因此总成本约为 51 美元。

Update更新

Using Lambda or Step Functions is probably not the most cost effective option because both ways you will need to read the file (that contains object keys) from some source such as S3.使用 Lambda 或 Step Functions 可能不是最具成本效益的选择,因为这两种方式都需要从某些源(如 S3)读取文件(包含对象键)。 So I think running the script from local machine or any EC2 linux screen appears to be the best option.所以我认为从本地机器或任何 EC2 linux 屏幕运行脚本似乎是最好的选择。

Delete operations are for free.删除操作是免费的。 You can create a lifecycle Policy to automate a bulk delete.您可以创建生命周期策略来自动执行批量删除。

I would start with a small number of objects first and check billing report to 100% confirm that the delete will not be charged, then go for the rest.我会先从少量对象开始,然后检查帐单报告以 100% 确认删除不会收费,然后再进行其余的操作。

In 2021, anyone who comes across this question may benefit to know that AWS console now provides an empty button. 2021 年,任何遇到此问题的人都可能会受益于 AWS 控制台现在提供了一个按钮。

Select the bucket and click on "empty" button and all objects versioned or not versioned would be emptied/deleted.选择存储桶并单击“清空”按钮,所有受版本控制或未受版本控制的对象都将被清空/删除。 Depending on the number of objects it can take minutes to days.根据对象的数量,这可能需要几分钟到几天的时间。

Try the S3Browser试试S3Browser

It worked well for me when deleted several tens of millions of objects当删除数千万个对象时,它对我来说效果很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM