Failed to query available provider packages error


So I’m having some trouble when running terraform init using the kubernetes-engine module:

In terraform I put in:

version                = "19.0.0"

like how it mentions at the top right corner on the page. However when I go about running terraform init, it gives me the following error:

Successfully configured the backend "gcs"! Terraform will automatically

use this backend unless the backend configuration changes.

Initializing provider plugins...

- Finding latest version of hashicorp/external...

- Finding hashicorp/google versions matching ">= 3.53.0, >= 4.0.0, < 5.0.0"...

- Finding hashicorp/kubernetes versions matching "~> 2.0"...

- Finding latest version of hashicorp/random...

- Finding latest version of hashicorp/null...

- Using previously-installed hashicorp/null v3.1.0

- Using previously-installed hashicorp/external v2.2.0

- Installing hashicorp/kubernetes v2.8.0...

- Installed hashicorp/kubernetes v2.8.0 (signed by HashiCorp)

- Using previously-installed hashicorp/random v3.1.0


│ Error: Failed to query available provider packages


│ Could not retrieve the list of available versions for provider hashicorp/google: no available

│ releases match the given constraints >= 3.53.0, >= 4.0.0, < 5.0.0

However, when I go to google hashicorp, it says that the provider version is currently at 4.10.0?

Any ideas?

Version 19.0.0 is the version of the module, while 4.10.0 is the version of the provider.

Could you show your code? Where have you set versions?

I have set the versions here:

provider "google" {
  project      = "test-project"
  region       = var.region

terraform {
  required_version = ">=0.14"

terraform {
  backend "gcs" {
    bucket = "tf-state-for-${PROJECT_NAME}-${ENV_NAME}"
    prefix = "gke"

locals {
  master_authorized_networks_list = flatten([
    for cidr_name, cidr_ips in var.master_authorized_networks : [
      for cidr_ip in cidr_ips : {
        cidr_block   = cidr_ip
        display_name = cidr_name

module "kubernetes-engine" {
  source                          = "terraform-google-modules/kubernetes-engine/google//modules/private-cluster-update-variant"
  version                         = "19.0.0"
  project_id                      = var.project
  region                          = var.region
  zones                           = ["us-central1-a", "us-central1-b", "us-central1-c"]
  name                            = format(var.cluster_name, var.env_name)
  network                         = format(var.vpc_network_name, var.vpc_env)
  subnetwork                      = format(var.subnetwork, var.env_name)
  ip_range_pods                   = format(var.ip_range_pods, var.env_name)
  ip_range_services               = format(var.ip_range_services, var.env_name)
  kubernetes_version              = "1.21.6-gke.1500"
  master_authorized_networks      = local.master_authorized_networks_list
  enable_vertical_pod_autoscaling = var.enable_vertical_pod_autoscaling
  horizontal_pod_autoscaling      = var.horizontal_pod_autoscaling
  http_load_balancing             = var.http_load_balancing
  network_policy                  = var.network_policy
  network_policy_provider         = var.network_policy_provider
  maintenance_start_time          = var.maintenance_start_time
  maintenance_exclusions          = var.maintenance_exclusions
  initial_node_count              = var.initial_node_count
  remove_default_node_pool        = var.remove_default_node_pool
  node_pools = [for node in var.node_pools :
      name               =
      machine_type       = node.machine_type
      region             = node.region
      min_count          = node.min_count
      max_count          = node.max_count
      disk_size_gb       = node.disk_size_gb
      disk_type          = node.disk_type
      image_type         = node.image_type
      auto_repair        = true
      auto_upgrade       = true
      service_account    = node.service_account
      preemptible        = node.preemptible
      initial_node_count = node.initial_node_count
      enable_secure_boot = node.enable_secure_boot

This module declares its own provider requirements:

A module declaring both a minimum and a maximum bound for providers is unusual unless the authors already know that the module is incompatible with a specific newer version of the provider, so I’m surprised to see this version constraint but I assume the module authors have a good reason for setting it, and in any event I don’t think it’s the cause of your error.

Terraform will combine all of the version constraints for hashicorp/google across all modules in your configuration, and so the constraint shown in the error message >= 3.53.0, >= 4.0.0, < 5.0.0 suggests that there’s some other module in your configuration which is specifying >= 3.53.0 but that doesn’t matter because that extra constraint is a superset of >= 4.0.0, < 5.0.0 and so the module’s own constraint will take priority here.

(Incidentally, you can run terraform providers to see which provider constraints each module in your configuration is setting. Its information may be more limited if terraform init can’t succeed as in this case, but it should still be able to show the version constraints from each module.)

As you noted, there is currently a v4.10.0 release which should be matched by this version constraint, and so the fact that it isn’t working suggests a local issue on your system. For example:

  • Have you customized any of the provider-installation-related settings in the CLI configuration? That can potentially change where Terraform looks for particular providers, including disabling its default behavior of consulting the Terraform Registry.
  • Have you installed an older version of this provider manually before into one of the implied local mirror directories? Any providers installed there will implicitly disable installing from the origin registry on the assumption that you installed the provider manually with the intention of using your local copy instead.
1 Like