[英]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.