Terraform 销毁错误 'Instance cannot be destroyed' 和 'Failed getting S3 bucket'
Terraform destroy error 'Instance cannot be destroyed' and 'Failed getting S3 bucket'
我目前正在尝试销毁工作区,我知道有些存储桶应用了 'do not destroy' 类型标签,所以当我 运行 terraform destroy
for第一次,我得到了两个桶的 Instance cannot be destroyed
错误:
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
,然后它抱怨我手动删除的一个存储桶:Failed getting S3 bucket: NotFound: Not Found
, 另一个好像没问题。
有谁知道如何解决这个问题吗?谢谢。
如果您通过 Terraform 状态修改之外的操作删除了资源(在这种情况下,通过控制台手动删除了存储桶),那么您需要相应地更新 Terraform 状态。您可以使用 terraform state
子命令执行此操作。鉴于您列出的名为 module.xxx.aws_s3_bucket.xxx_bucket
的资源示例,它看起来像:
terraform state rm module.xxx.aws_s3_bucket.xxx_bucket
您可以在 documentation 中找到更多信息。
我目前正在尝试销毁工作区,我知道有些存储桶应用了 'do not destroy' 类型标签,所以当我 运行 terraform destroy
for第一次,我得到了两个桶的 Instance cannot be destroyed
错误:
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
,然后它抱怨我手动删除的一个存储桶:Failed getting S3 bucket: NotFound: Not Found
, 另一个好像没问题。
有谁知道如何解决这个问题吗?谢谢。
如果您通过 Terraform 状态修改之外的操作删除了资源(在这种情况下,通过控制台手动删除了存储桶),那么您需要相应地更新 Terraform 状态。您可以使用 terraform state
子命令执行此操作。鉴于您列出的名为 module.xxx.aws_s3_bucket.xxx_bucket
的资源示例,它看起来像:
terraform state rm module.xxx.aws_s3_bucket.xxx_bucket
您可以在 documentation 中找到更多信息。