地形销毁错误"无法销毁实例"和"获取 S3 存储桶失败"



我目前正在尝试销毁一个工作区,我知道有些bucket应用了"不销毁"类型的标记,所以当我第一次运行terraform destroy时,我得到了两个bucket的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,然后它抱怨我手动删除的一个bucket:Failed getting S3 bucket: NotFound: Not Found,另一个似乎很好。

有人知道如何解决这个问题吗?谢谢

如果您在Terraform状态下通过修改外部的操作删除了资源(在这种情况下,是通过控制台手动删除的bucket(,那么您需要相应地更新Terraform状态。可以使用terraform state子命令执行此操作。给定您列出的名为module.xxx.aws_s3_bucket.xxx_bucket的资源示例,它看起来像:

terraform state rm module.xxx.aws_s3_bucket.xxx_bucket

您可以在文档中找到更多信息。

最新更新