简体   繁体   English

如果设置了 prevent_destroy 生命周期,则 Terraform 计划显示错误

[英]Terraform plan showing error if prevent_destroy lifecycle is set

Getting below error while running Terraform Plan or Terraform refresh, How to resolve this.运行 Terraform 计划或 Terraform 刷新时出现以下错误,如何解决此问题。

Error: Instance cannot be destroyed错误:无法销毁实例

on ..\ec2\ec2.tf line 89: 89: resource "aws_instance" "strdicomdev" {在 ..\ec2\ec2.tf 第 89 行:89:资源“aws_instance”“strdicomdev”{

Resource module.ec2.aws_instance.strdicomdev has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed.资源 module.ec2.aws_instance.strdicomdev 设置了生命周期.prevent_destroy,但计划要求销毁此资源。 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.要避免此错误并继续执行计划,请禁用生命周期.prevent_destroy 或使用 -target 标志缩小计划范围。

Releasing state lock.释放状态锁。 This may take a few moments...这可能需要一些时间...

The answer is in the error message:答案在错误消息中:

module.ec2.aws_instance.strdicomdev has lifecycle.prevent_destroy

If you look at this module it will have a lifecycle stanza which includes prevent_destroy = true.如果您查看此模块,它将有一个生命周期节,其中包括 prevent_destroy = true。 Since it's a module, maybe it is has a variable to control this, and the default is to prevent destroy.既然是模块,也许它有一个变量来控制它,默认是防止破坏。 The easiest thing to do is to remove the prevent_destroy part of the lifecycle stanza or set it to false (either by changing the module or setting the variable if the module uses one)最简单的做法是删除生命周期节的 prevent_destroy 部分或将其设置为 false(通过更改模块或设置变量,如果模块使用一个)

暂无
暂无

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

相关问题 如何在 Terraform 中参数化 prevent_destroy 生命周期配置? - How to parameterize prevent_destroy lifecycle configuration in Terraform? Terraform Destroy Command 显示不正确的计划 - Terraform Destroy Command shows improper plan terraform 计划抛出 Unsupported argument and attribute cannot be set 错误 - terraform plan throws Unsupported argument and attribute cannot be set error terraform 错误:tf 计划中的模块中的参数不受支持 - terraform error: unsupported argument in module in tf plan 手动移动 terraform state 文件并运行 terraform 计划时出错 - Error when manually moving terraform state file and running terraform plan 运行 Terraform 计划/应用时出现 InvalidClientTokenID 错误 - InvalidClientTokenID error when running Terraform Plan/Apply terraform 给出错误:运行 terraform 计划时模块中的参数不受支持? - terraform giving error: unsupported argument in module when running terraform plan? Terraform 错误:运行 terraform 计划时条件类型不正确 - Terraform Error: Incorrect condition type when running terraform plan Terraform (0.12.29) 导入未按预期工作; 导入成功,但计划显示销毁和重新创建 - Terraform (0.12.29) import not working as expected; import succeeded but plan shows destroy & recreate terraform init和terraform计划成功运行后,terraform应用S3报告后端配置错误 - terraform apply reporting backend configuration error with S3 after terraform init & terraform plan worked successfully
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM