amazon-web-services - Terraform 破坏错误 'Instance cannot be destroyed' 和 'Failed getting S3 bucket'

标签 amazon-web-services amazon-s3 terraform terraform-provider-aws

我目前正在尝试销毁工作区,我知道有些存储桶应用了“不销毁”类型标签,因此当我第一次运行 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/

相关文章:

php - 亚马逊AWS中的任务/队列管理

python - 如何使用 AWS S3 策略强制联合用户的资源所有权?

php - 如何使用 Gaufrette 和 Symfony 3.0

Azure AKS 错误 : Kubernetes cluster unreachable dial tcp no such host 443

linux - 如何将 linux bash 脚本文件添加到 terraform 代码中?

amazon-web-services - 使用 groovy 脚本更新 jenkins 文件中的 aws 凭证

ios - 如何生成 "AWS Authentication String"以从 iOS 向 CloudFront 发送 POST?

azure 资源专用端点创建错误

node.js - 从 URL 获取图像到 S3

amazon-web-services - 是否可以将数据从 Redshift 传输到 Elasticsearch?