为什么 'terraform apply' 试图破坏工作区中的所有其他内容?
Why 'terraform apply' is trying to destroy everything else in the workspace?
我有一个单独的 repo 用于存储一些新的 terraform 脚本(lambda 的定义和链接到 lambda 的 S3 存储桶),我在同一工作区的不同 repo 中定义了一些基础设施。
当我 运行 Terraform apply
它试图破坏其他仓库中定义的所有其他内容并添加此仓库中定义的新基础架构时,这是为什么?我怎样才能保留所有这些?
我发现存储在我本地机器上的状态是 version 3
而存储在 S3 存储桶中的状态显示 version 4
,并且内容不同,这可能是问题所在吗?
I found that the state stored on my local machine is version 3 whereas
the state stored in S3 bucket shows version 4, and the content is
different, could this be the issue?
是的。
确保您的状态是由相同的 terraform 版本生成的。
如果您无法修复州版本差异,您可以使用 import function 将这些资源导入您的州。
$ terraform import aws_instance.example i-abcd1234
我有一个单独的 repo 用于存储一些新的 terraform 脚本(lambda 的定义和链接到 lambda 的 S3 存储桶),我在同一工作区的不同 repo 中定义了一些基础设施。
当我 运行 Terraform apply
它试图破坏其他仓库中定义的所有其他内容并添加此仓库中定义的新基础架构时,这是为什么?我怎样才能保留所有这些?
我发现存储在我本地机器上的状态是 version 3
而存储在 S3 存储桶中的状态显示 version 4
,并且内容不同,这可能是问题所在吗?
I found that the state stored on my local machine is version 3 whereas the state stored in S3 bucket shows version 4, and the content is different, could this be the issue?
是的。
确保您的状态是由相同的 terraform 版本生成的。
如果您无法修复州版本差异,您可以使用 import function 将这些资源导入您的州。
$ terraform import aws_instance.example i-abcd1234