首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Terraform:如何自动解决从旧状态文件中删除的提供程序问题?

Terraform:如何自动解决从旧状态文件中删除的提供程序问题?
EN

Stack Overflow用户
提问于 2021-12-21 20:28:26
回答 2查看 4.4K关注 0票数 2

我正在将模板从terraform 0.12.31升级到0.13.7,我们需要确保我们有一个自动系统来处理在旧版本下创建的部署。

我正在解决的一个问题是,我删除了移动过程中所有null提供程序的使用。当我尝试在0.12上创建的状态文件上应用或规划时,当使用terraform版本0.13时,我会收到以下错误:

代码语言:javascript
运行
复制
$ terraform plan --var-file MY_VAR_FILE.json 
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.

Error: Provider configuration not present

To work with
module.gcp_volt_site.module.ce_config.data.null_data_source.hosts_localhost
its original provider configuration at
provider["registry.terraform.io/-/null"] is required, but it has been removed.
This occurs when a provider configuration is removed while objects created by
that provider still exist in the state. Re-add the provider configuration to
destroy
module.gcp_volt_site.module.ce_config.data.null_data_source.hosts_localhost,
after which you can remove the provider configuration again.


Error: Provider configuration not present

To work with
module.gcp_volt_site.module.ce_config.data.null_data_source.cloud_init_master
its original provider configuration at
provider["registry.terraform.io/-/null"] is required, but it has been removed.
This occurs when a provider configuration is removed while objects created by
that provider still exist in the state. Re-add the provider configuration to
destroy
module.gcp_volt_site.module.ce_config.data.null_data_source.cloud_init_master,
after which you can remove the provider configuration again.


Error: Provider configuration not present

To work with
module.gcp_volt_site.module.ce_config.data.null_data_source.vpm_config its
original provider configuration at provider["registry.terraform.io/-/null"] is
required, but it has been removed. This occurs when a provider configuration
is removed while objects created by that provider still exist in the state.
Re-add the provider configuration to destroy
module.gcp_volt_site.module.ce_config.data.null_data_source.vpm_config, after
which you can remove the provider configuration again.

我的手动解决方案是在列出的所有模块上运行terraform state rm

代码语言:javascript
运行
复制
terraform state rm module.gcp_volt_site.module.ce_config.data.null_data_source.vpm_config
terraform state rm module.gcp_volt_site.module.ce_config.data.null_data_source.hosts_localhost
terraform state rm module.gcp_volt_site.module.ce_config.data.null_data_source.cloud_init_master

我想知道如何自动完成此操作,以使脚本能够进行这些更改。

我是否可以使用terraform命令列出这些删除的模块,而不需要额外的测试,这样我就可以循环运行terraform state rm来从状态文件中删除它们了吗?

或者是否有某种terraform命令可以以通用方式(如terraform state rm -all-not-present )自动完成此操作?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70441257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档