スキップしてコンテンツを表示

Delete object only with standard storage class in S3

0

I have an S3 bucket containing 7 TB of data, with approximately 6 TB stored in the Standard storage class (around 40 million objects) and the rest in Glacier. I need to delete all objects in the Standard storage class while retaining those in Glacier. Since the objects are randomly distributed within the bucket, there is no specific folder to target for Standard storage class objects, making lifecycle rules unsuitable for this task.

can somebody suggest an efficient and straightforward approach to achieve this?

Thanks!

1回答
0

A simple shell script should work

List objects with storage class

aws s3api list-objects --bucket YOUR_BUCKET_NAME --query "Contents[?StorageClass=='STANDARD'].[Key]" --output text

Delete only standard class objects

aws s3api list-objects --bucket YOUR_BUCKET_NAME --query "Contents[?StorageClass=='STANDARD'].[Key]" --output text | xargs -I {} aws s3 rm s3://YOUR_BUCKET_NAME/{}

Please test before performing in your Bucket

エキスパート
回答済み 10ヶ月前
エキスパート
レビュー済み 10ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ