我有以下问题。假设我有此设置:
Main.tf
resource "aws_security_group" "vpc_security_group" {
name = var.security_group_name
...
}
variables.tf
variable "security_group_name" {
type = string
}
my_var_file.tfvars
security_group_name = "foo"
我有一个指向AWS S3存储桶的后端。
我前一段时间应用了它,它生成了一个tfplan文件和.tfstate
个文件。现在,我想更改安全组的名称(除其他外),以便我的.tfvars
文件看起来像这样
security_group_name = "bar"
如果我执行以下操作:
$ terraform init
$ terraform plan -var-file="my_var_file.tfvars" -out "tfplan.out"
我注意到该计划包括创建一个名称为“ foo”而不是“ bar”的安全组,就像它没有注意var文件中的更新值一样:
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_security_group.vpc_security_group: Refreshing state... [id=foo:terraform-20201014191031939100000001]
plan
命令中是否需要包含一些内容以使其忽略先前的计划?
谢谢