Configuration_aliases for multiple providers not working

Hello All,

Iam having two providers for my Kubenretes which are going to be used by the modules.
Below one is the code for the version.tf file

terraform {
required_version = “>= 0.15”

required_providers {
cloudflare = {
source = “cloudflare/cloudflare”
version = “~> 2.11.0”
}
kubernetes = {
source = “hashicorp/kubernetes”
version = “2.0.0”
configuration_aliases = [ kubernetes.gke ]

  source  = "hashicorp/kubernetes"
  version = "1.7.0"
  configuration_aliases = [ kubernetes.gke_v2 ]
}

So I also have a provider .tf file which having data like this

provider “kubernetes” {
alias = “gke”
host = module.gke.gke_cluster_endpoint
token = module.gke.google_client_config_access_token
cluster_ca_certificate = base64decode(module.gke.gke_cluster_cluster_ca_certificate)
}

provider “kubernetes” {
alias = “gke_v2”
kubernetes {
host = module.gke.gke_cluster_endpoint
cluster_ca_certificate = base64decode(module.gke.gke_cluster_cluster_ca_certificate)
token = module.gke.google_client_config_access_token
}
}

And in my modules im adding like

module “istio-base” {
providers = {
kubernetes = kubernetes.gke
helm = helm.helm
}
istio_values = [file(“environment/${var.environment}/istio-values.yaml”)]
source = “”
depends_on = [module.gke, kubernetes_namespace.istio_system_namespace]
}

But the issue is that when im doing the terraform init command. Its only taking one version like below

Initializing provider plugins…

  • Finding hashicorp/null versions matching “~> 2.1”…
  • Finding cloudflare/cloudflare versions matching “~> 2.11.0”…
  • Finding hashicorp/kubernetes versions matching “1.7.0”…
  • Finding hashicorp/google versions matching “3.64.0”…
  • Finding hashicorp/google-beta versions matching “3.64.0”…
  • Finding hashicorp/helm versions matching “0.10.6”…
  • Finding hashicorp/random versions matching “2.3.0”…
  • Using previously-installed cloudflare/cloudflare v2.11.0
  • Using previously-installed hashicorp/kubernetes v1.7.0
  • Using previously-installed hashicorp/google v3.64.0
  • Using previously-installed hashicorp/google-beta v3.64.0
  • Using previously-installed hashicorp/helm v0.10.6
  • Using previously-installed hashicorp/random v2.3.0
  • Using previously-installed hashicorp/null v2.1.2

and sometimes it will say like below error

Error: Failed to query available provider packages

│ Could not retrieve the list of available versions for provider hashicorp/kubernetes: no available releases match the given constraints 1.7.0, 2.0.0

Can anyone tell where its wrong.

Regards,
Soju George

1 Like