Versioned Bucket Delete All Objects and bucket

0

If I have a bucket that is versioned. What CLI command can delete all versions of all objects as well as the bucket? I ran the aws s3 rm command but it did not delete all versions of the objects.

Thanks

질문됨 2달 전229회 조회
1개 답변
1
수락된 답변

Hello.

You cannot delete versioned bucket objects in bulk using the AWS CLI, so you need to create a shell script as shown below.
However, while this method works if there are few objects, if there are tens of thousands of objects, I think it is easier to set up lifecycle rules to delete them.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html

bucket=hoge-bucket && aws s3api list-object-versions --bucket $bucket | jq -r '.Versions[] | [.Key, .VersionId] |@tsv' | while read k v;do aws s3api delete-object --bucket $bucket --key $k --version-id $v; done
profile picture
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠