未找到 terraform kubectl 提供程序

Pad*_*adi 8 kubernetes terraform kubectl terraform-provider-gcp

我正在尝试为 terraform 模块添加 kubectl 提供程序,我遵循Terraform kubectl的文档。我运行terraform init并成功安装了提供程序,但是当我尝试添加示例配置时,例如:(或来自此处的其他人

resource "kubectl_server_version" "current" {}
Run Code Online (Sandbox Code Playgroud)

并运行terraform plan我得到以下消息:

Error: Could not load plugin
Failed to instantiate provider "registry.terraform.io/hashicorp/kubectl" to
obtain schema: unknown provider "registry.terraform.io/hashicorp/kubectl"
Run Code Online (Sandbox Code Playgroud)

当我调整时terraform init(资源在模块 k8s 中就位)

Error: Failed to install provider

Error while installing hashicorp/kubectl: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/kubectl
Run Code Online (Sandbox Code Playgroud)

一些输出:

$terraform plugins

??? provider[registry.terraform.io/hashicorp/kubernetes] 1.13.2
??? provider[registry.terraform.io/gavinbunney/kubectl] 1.9.1
??? module.k8s
?   ??? provider[registry.terraform.io/hashicorp/kubectl]
?   ??? provider[registry.terraform.io/hashicorp/kubernetes]



$terraform init

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Using previously-installed hashicorp/kubernetes v1.13.2
- Using previously-installed gavinbunney/kubectl v1.9.1

$terraform -v

Terraform v0.13.4
  + provider registry.terraform.io/gavinbunney/kubectl v1.9.1
  + provider registry.terraform.io/hashicorp/kubernetes v1.13.2
  ....
Run Code Online (Sandbox Code Playgroud)

一些配置文件:

地形.tf

terraform {

  required_version  = "0.13.4"

  backend "gcs" {
    ...
  }

  required_providers {
    kubernetes = {
        source        = "hashicorp/kubernetes"
        version       = "1.13.2"
      }

    kubectl = {
      source          = "gavinbunney/kubectl"
      version         = "1.9.1"
    }
....
Run Code Online (Sandbox Code Playgroud)

terraform 成功初始化gavinbunney/kubectl提供程序但是当我添加resource "kubectl_manifest" ...k8s.module terraform 正在尝试加载hashicorp/kubectl提供程序

我错过了什么?:)

Pad*_*adi 2

似乎问题是我在同一模块中resource "kubectl_server_version" "current" {}的资源中拥有其他资源hashicorp/kubernetes,并且 terraform 试图kubectlhashicorp/kubectl.

当我在 main.tf 中添加gavinbunney/kubectl资源时,一切正常:)