0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【aws cli】バージョニングが有効なS3バケットの削除方法

Posted at

S3バケットのバージョニングが有効な場合、S3バケットを削除しようとしても失敗してしまいます。

そのためのコードをメモ代わりに記載しています。

※下記の例では、S3バケット名はbucket-name-sampleとしています。

deleteS3.sh
#!/usr/bin/env bash

# バケット内のオブジェクトを削除
aws s3api delete-objects --bucket bucket-name-sample --delete "$(aws s3api list-object-versions --bucket bucket-name-sample | jq '{Objects: [.Versions[] | {Key:.Key, VersionId : .VersionId}], Quiet: false}')"

# S3バケットを削除
aws s3 rm s3://bucket-name-sample --recursive

これでS3バケットの削除が成功します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?