Introduction
Problem
Missing or updated proxy settings may report this error while using Terraform to provision Kubernetes Resources. Proxy settings may be valid locally, but if they are missing from the Terraform Enterprise environment you may experience vague authentication errors such as this one.
Get "https://xx.xx.xx.xx/apis": authenticationrequired
Error: Invalid configuration for API client
Prerequisites (if applicable)
This example uses GKE with Terraform and the Resource: kubernetes_manifest.
terraform { required_providers { kubernetes = { source = "hashicorp/kubernetes" version = "2.7.1" } } }
data "google_client_config" "provider" {}
data "google_container_cluster" "test_cluster" {
name = "test-cluster"
location = "us-central1"
}
provider "kubernetes" {
host = "https://${data.google_container_cluster.test_cluster.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.test_cluster.master_auth[0].cluster_ca_certificate,
)
}
resource "kubernetes_manifest" "test-configmap" {
manifest = {
"apiVersion" = "v1"
"kind" = "ConfigMap"
"metadata" = {
"name" = "test-config"
"namespace" = "default"
}
"data" = {
"foo" = "bar"
}
}
}
on ../main.tf line 23, in resource "kubernetes_manifest" "test-configmap
":
23: resource "kubernetes_manifest" "test-configmap
" {
Get "https://xx.xx.xx.xx/apis": authenticationrequired
Error: Invalid configuration for API client
Cause
- Missing or changed proxy settings from the environment where Terraform is deployed is known to cause this issue.
- This can be confirmed and reproduced locally by making the same proxy changes or disabling proxy.
Overview of possible solutions (if applicable)
Solutions:
-
Check that your proxy settings are configured in the variables tab on the Terraform Enterprise workspace.