简体   繁体   English

aws s3 存储桶删除问题

[英]aws s3 bucket delete issue

I am deleting bucket from AWS S3 and versioning is enabled, but it's showing this error:我正在从 AWS S3 中删除存储桶并启用版本控制,但它显示此错误:

aws_s3_bucket.bucket: Error deleting S3 Bucket: BucketNotEmpty: The bucket you tried to delete is not empty. aws_s3_bucket.bucket:删除 S3 存储桶时出错:BucketNotEmpty:您尝试删除的存储桶不为空。 You must delete all versions of the bucket.您必须删除存储桶的所有版本。

resource "aws_s3_bucket" "bucket" {
  bucket        = "${module.naming.aws_s3_bucket}"
  acl           = "log-delivery-write"
  force_destroy = true

versioning {
    enabled = true
  }
}

I am using Terraform version 10.8我正在使用 Terraform 版本 10.8

force_destroy is not applying because it only can affect the aws s3 bucket directly. force_destroy不适用,因为它只能直接影响aws s3存储桶。 Not inherit with it's containing childs.不继承它包含的孩子。

If you want to delete all objects you need to run:如果要删除需要运行的所有对象:

aws s3 rm s3://name-of-bucket --recursive

To get rid of all versions within the object that are still existing you better run:要删除 object 中仍然存在的所有版本,您最好运行:

aws s3api delete-objects --bucket name-of-bucket --delete '{"Objects": [{"Key": "*", "VersionId": "*"}]}'

To be fair to others who tried to answer your question it is indeed the obvious answer, no, force_destroy can't manage that.对其他试图回答您问题的人公平地说,这确实是显而易见的答案,不,force_destroy 无法做到这一点。 But I hope my explanation can give you an inside why it is the case.但我希望我的解释能给你一个内在的原因。 Good luck!祝你好运!

"force_destroy": true,
"versioning": [
              {
                "enabled": true,
                "mfa_delete": false
              }

is working as expected正在按预期工作

I have Terraform v0.13.4我有 Terraform v0.13.4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM