我目前正在尝试销毁工作区,我知道有些存储桶应用了“不销毁”类型标签,因此当我第一次运行 terraform destroy
时一次,我收到两个存储桶的实例无法销毁
错误:
Resource module.xxx.aws_s3_bucket.xxx_bucket has
lifecycle.prevent_destroy set, but the plan calls for this resource to be
destroyed. To avoid this error and continue with the plan, either disable
lifecycle.prevent_destroy or reduce the scope of the plan using the -target
flag.
所以我导航到AWS控制台并手动删除它们,然后尝试再次运行terraform destroy
,然后它提示我手动删除的存储桶之一:无法获取S3存储桶:NotFound:未找到
,另一个似乎没问题。
请问有谁知道如何解决这个问题吗?谢谢。
最佳答案
如果您使用 Terraform 状态修改之外的操作删除了资源(在这种情况下,通过控制台手动删除存储桶),那么您需要相应地更新 Terraform 状态。您可以使用 terraform state
子命令来执行此操作。鉴于您列出的名为 module.xxx.aws_s3_bucket.xxx_bucket
的资源示例,它看起来像:
terraform state rm module.xxx.aws_s3_bucket.xxx_bucket
您可以在 documentation 中找到更多信息.
关于amazon-web-services - Terraform 破坏错误 'Instance cannot be destroyed' 和 'Failed getting S3 bucket',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64464167/