Kubernetes Backend : Cannot reuse after restoring the k8s cluster

Can’t seam to reuse the k8s backend after restoring from a backup the k8s cluster (Rancher here)… I think the certificate might have changed but is still valid (ACME), but can’t seam to make it work.

My config:

terraform {
  backend "kubernetes" {
    namespace     = "tfstate-crke"
    secret_suffix = "crke"
    host          = "https://XXXXXXXX/k8s/clusters/local"
    token         = "XXXXXXX"
  }
}

Tried with different versions:

1.0.11: Error: Failed to get existing workspaces: Get "https://XXXXXXXXX/k8s/clusters/local/api/v1/namespaces/tfstate-crke/secrets?labelSelector=tfstate%3Dtrue": x509: certificate signed by unknown authority

  • The certificate is valid, a curl on that URL doesn’t give me a TLS error!

1.1.8 and +: Error: Failed to initialize kubernetes configuration: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable