问题描述
从 Glacier 获取对象非常耗时,因此我决定改用 S3 IA 存储类.我需要列出我的存储桶中具有 Glacier 存储类的所有对象(我通过 LifeCycle 策略对其进行了配置)并将其更改为 S3 IA.
It's very time consuming to get objects from Glacier so I decided to use S3 IA storage class instead.I need to list all the objects in my bucket that have Glacier storage class (I configured it via LifeCycle policy) and to change it to S3 IA.
是否有任何脚本或工具?
Is there any script or a tool for that?
推荐答案
您可以使用 列表对象
list-objects
将返回 StorageClass
,在您的情况下,您要过滤 GLACIER
list-objects
will return the StorageClass
, in your case you want to filter for values where it is GLACIER
aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`]'
你想要的只是得到匹配的 Key 列表
What you want then is to get only the list of Key that matches
aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`][Key]' --output text
然后你需要通过改变Key的存储类来复制对象
Then you will need to copy the object with changing the storage class of the Key
aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`][Key]' --output text
| xargs -I {} aws s3 cp s3://bucket_name/{} s3://bucket_name/{} --storage-class STANDARD_IA
这篇关于列出具有特定存储类的 S3 存储桶对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!