0

我正在使用 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.

解决方法是什么?

4

1 回答 1

0

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

terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
}
于 2022-01-31T10:56:17.863 回答