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?

【S3】Error: deleting S3 Bucket (Bucket-name):operation error S3: DeleteBucket, https response error StatusCode: 409, api error BucketNotEmpty: The bucket you tried to delete is not empty. You must delete all versions in the bucket. の解決方法

0
Posted at

はじめに

S3オブジェクトの削除を目的として Terraform Apply を実施したところ、表題のエラーが発生しました。

問題

s3のバケットのTerraformモジュールを削除後、Applyを実施したところ、以下のエラーが発生しました。

Error: deleting S3 Bucket (Bucket-name): operation error S3: DeleteBucket, https response error StatusCode: 409, RequestID: XXXXX, HostID: XXXXX, api error BucketNotEmpty: The bucket you tried to delete is not empty. You must delete all versions in the bucket.

原因

S3バケット内のオブジェクトを事前に削除していなかったためです。

解決方法

AWSコンソールでS3バケット内のデータを削除しました。

バージョニングを有効にしている場合、バージョニングされたオブジェクトも削除しないと、同じエラーが再発します。

バージョンの表示のトグルをONにしてバージョニングデータを表示、削除しました。

image.png

おわりに

バージョニングされたオブジェクトまで削除する必要がある点は盲点でした。
Terraformでforce_destroy = trueを定義してApplyする方法でも解消できるようです。

参考

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?