Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

"Invalid attribute in provider configuration" with dynamic provider configuration #174

Closed
lawliet89 opened this issue Mar 17, 2021 · 5 comments
Labels
question Further information is requested

Comments

@lawliet89
Copy link

Terraform, Provider, Kubernetes versions

Terraform version: 0.14.8
Provider version: 0.3.1
Kubernetes version: 1.18.12

Affected Resource(s)

  • Provider configuration

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

data "google_client_config" "default" {
}

data "terraform_remote_state" "gke" {
  backend = "gcs"

  config = {
    bucket = "somebucket"
    prefix = "someprefix"
  }
}


provider "kubernetes-alpha" {
  host                   = data.terraform_remote_state.gke.outputs.endpoint
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.terraform_remote_state.gke.outputs.ca_certificate)
}

Debug Output

Panic Output

Steps to Reproduce

  1. terraform plan

Expected Behavior

What should have happened?

A plan to be displayed.

Actual Behavior

What actually happened?

Invalid attribute in provider configuration

  on main.tf line 6, in provider "kubernetes-alpha":
   6: provider "kubernetes-alpha" {

'host' is not a valid URL


Error: Failed to get RESTMapper client

cannot create discovery client: no client config

ERRO[0003] Hit multiple errors:

Important Factoids

This is a variation of #147 that now appears with >= 0.3.1.

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@alexsomesan
Copy link
Member

@lawliet89 The error message tries to be helpful there. It says: 'host' is not a valid URL

See below the configuration that works in my tests. The only difference I can spot is putting "https://' in front of the value of the endpoint value. In GKE, the endpoint seems to just be an IP address.

data "google_client_config" "current" {}

data "terraform_remote_state" "gke" {
  backend = "local"

  config = {
    path = "/Users/alex/work/terraform-provider-kubernetes/kubernetes/test-infra/gke/terraform.tfstate"
  }
}

provider "kubernetes-alpha" {
  token                  = data.google_client_config.current.access_token
  host                   = "https://${data.terraform_remote_state.gke.outputs.cluster_api}"
  cluster_ca_certificate = base64decode(data.terraform_remote_state.gke.outputs.cluster_ca)
}

resource "kubernetes_manifest" "test-configmap" {
  provider = kubernetes-alpha
  manifest = {
    "apiVersion" = "v1"
    "kind"       = "ConfigMap"
    "metadata" = {
      "name"      = "test-config"
      "namespace" = "default"
      "labels" = {
        "app"         = "test-app"
        "environment" = "production"
      }
    }
    "data" = {
      "foo" = "bar"
    }
  }
}

Let me know if that works in your case.

@alexsomesan alexsomesan added question Further information is requested waiting-response and removed bug Something isn't working labels Mar 17, 2021
@davidalger
Copy link

@alexsomesan I would consider this a bug, which is why I opened #141. The official kubernetes and helm providers do not have this problem where the host must be a fully qualified URL, they accept the IP address and automatically use https to connect.

@ghost ghost removed waiting-response labels Mar 17, 2021
@alexsomesan
Copy link
Member

@davidalger Indeed, the other providers will optimistically try to deduce the URL when parts are omitted. To be fair, that behaviour is undocumented and the official documentation of all three providers does specify this attribute should be a URL.

We'll make changes to align to that behaviour, for consistency.

@lawliet89
Copy link
Author

@alexsomesan Adding https:// worked. Thanks! It wasn't very obvious for me TBH. Please feel free to close this issue.

@aareet aareet closed this as completed Mar 18, 2021
@ghost
Copy link

ghost commented Apr 17, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants