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
관련 콘텐츠
- AWS 공식업데이트됨 2년 전
What would be a good example Lifecycle Object Rule?
Followed the steps here:
https://repost.aws/knowledge-center/s3-empty-bucket-lifecycle-rule
Yes, the objects will be permanently deleted if you follow the settings described in the documentation you reviewed.