terraform kubectl provider not found terraform kubectl provider not found kubernetes kubernetes

terraform kubectl provider not found


In my case it was due to referencing kubectl resources in a module, but the module needed the provider adding to required_providers within the module:

terraform {  required_providers {    kubectl = {      source  = "gavinbunney/kubectl"      version = "x.x.x"    }  }}


Seems like the problem was that I had the resource "kubectl_server_version" "current" {} among with other resources from hashicorp/kubernetes resources in same module and terraform was trying to load kubectl from hashicorp/kubectl.

When I added gavinbunney/kubectl's resources in main.tf all works good :)


When I read the file cat .terraform/plugins/selections.json, I hunderstand that the package is not realy well installed.

In my project, I did :

cp -R .terraform/plugins/registry.terraform.io/gavinbunney/kubectl .terraform/plugins/registry.terraform.io/hashicorp

and after:

terraform init

This look to resolve the problem.