【问题标题】:Terraform : Error: Missing resource schema from provider. No resource schema found for local_fileTerraform:错误:缺少提供者的资源架构。找不到 local_file 的资源架构
【发布时间】:2022-01-31 18:56:17
【问题描述】:

我正在使用 terraform 版本 0.13.2,提供者 http://registry.terraform.io/hashicorp/local v2.1.0 并拥有以下资源:

terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
  required_version = ">= 0.13"
}

resource "local_file" "test_local_file" {
  content = "This is a test file"
  filename = "test.txt"
}

现在,当我仅在另一个目录中获取 terraform.tfstate 文件并尝试在新目录中使用 terraform 1.1.2 销毁此配置时,我在 terraform destroy 中收到以下错误:

│ Error: Missing resource schema from provider
│ 
│ No resource schema found for local_file.

解决方法是什么?

【问题讨论】:

  • 你能用required_providers 发布terraform 块吗?
  • @MarkoE 我已经用 terraform 块更新了问题
  • 啊等等,你说你将状态文件移动到另一个目录?

标签: terraform hashicorp


【解决方案1】:

使用 terraform v1.1.2,当您尝试仅使用状态文件删除配置时,terraform 不知何故无法获取本地提供程序。 修复方法是将local 提供程序块与状态文件一起包含在新目录中,然后执行terraform initterraform apply

terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
}

【讨论】:

  • 我在从配置中删除 local_file 资源时也遇到了这个问题。 local_file 资源仍然存在于状态文件中......这通常会提示 terraform 删除资源并将其从状态文件中删除,因为它不再是配置的一部分。相反,它抛出了这个错误。我最终只是使用 terraform state rm 将其从状态文件中删除。
猜你喜欢
  • 1970-01-01
  • 2019-04-06
  • 1970-01-01
  • 1970-01-01
  • 2019-09-22
  • 1970-01-01
  • 2019-07-25
  • 2018-07-30
  • 2018-11-11
相关资源
最近更新 更多