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

Viewed 3949

I am using terraform version 0.13.2, provider http://registry.terraform.io/hashicorp/local v2.1.0 and have the following resource :

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"
}

Now when I take only the terraform.tfstate file in another directory and try to destroy this configuration using terraform 1.1.2 in the new directory I get the following error on terraform destroy :

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

What is the fix?

2 Answers

Using terraform v1.1.2, when you try to delete the configuration using only the state file terraform is somehow not able to fetch the local provider. The fix is to include the local provider block in the new directory along with the state file and then perform terraform init, terraform apply

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

Error: Missing resource schema from provider

i found the solution as - find the file with .tfstate extension and edit this as per the requirement. Or delete this file and run terraform init and terraform plan command. issue will be resolved.

Related