问题描述
我有一个带有 Consul 远程后端的 terraform 0.14.1 项目,并且无法使用 terraform state
查看或修改状态。
项目树状结构如下,
.
└── environments
├── production
│ └── main.tf
└── test
└── main.tf
我可以毫无问题地运行以下命令(从包含目录 environments
的项目的根目录),
terraform init environments/test
terraform plan -out test.tfplan environments/test
terraform apply test.tfplan
但是,当我想使用以下命令查看状态时,
terraform state show module.foo
我收到错误,
Backend reinitialization required. Please run "terraform init".
Reason: Unsetting the prevIoUsly set backend "consul"
The "backend" is the interface that terraform uses to store state,perform operations,etc. If this message is showing up,it means that the
terraform configuration you're using is using a custom configuration for
the terraform backend.
Changes to backend configurations require reinitialization. This allows
terraform to setup the new configuration,copy existing state,etc. This is
only done during "terraform init". Please run that command Now then try again.
If the change reason above is incorrect,please verify your configuration
hasn't changed and try again. At this point,no changes to your existing
configuration or state have been made.
Error: Initialization required. Please see the error message above.
我可以再次运行 init
,但我仍然收到此消息。
看起来 state
命令不像其他一些命令那样有指向特定配置目录的选项。
作为一种解决方法,当我想使用 state 时,我将目录更改为 environments/test
并运行 terraform init .
。然后我可以查看和修改状态。
我是否忽略了什么,还是 terraform state
命令只是缺乏使用自定义配置目录的能力?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)