Could not retrieve the list of available versions for provider hashicorp/eks

Viewed 2279

I've followed the hashiCorp tutorial for deploying and EKS cluster. When using their tf file it succeeds init. If i use my tf file below it throws an error for terraform-aws-modules/eks and it makes no sense why it does that.

variable "region" {
  default     = "us-west-2"
  description = "AWS region"
}

provider "aws" {
  region = "us-west-2"
}

provider "kubernetes" {
  host                   = data.eks_cluster.cluster.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
  token                  = data.eks_cluster_auth.cluster.token
  load_config_file       = false
}

data "aws_availability_zones" "available" {}

data "eks_cluster" "cluster" {
  name = module.eks.cluster_id
}

data "eks_cluster_auth" "cluster" {
  name = module.eks.cluster_id
}

locals {
  cluster_name = "development-eks-${random_string.suffix.result}"
}

resource "random_string" "suffix" {
  length  = 8
  special = false
}


module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = local.cluster_name
  cluster_version = "1.17"
  subnets         = ["subnet-021510f2a4ad98fad","subnet-09ebbc7929c3859b4", "subnet-0a80ba106a29de364"]
  vpc_id          = "vpc-5b230723"

  tags = {
    environment = "development"
  }

  worker_groups = [
    {
      name                          = "worker-group-1"
      instance_type                 = "t2.samll"
      asg_desired_capacity          = 2
      additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id]
    }
  ]
}

Initializing modules... Downloading terraform-aws-modules/eks/aws 17.1.0 for eks...

  • eks in .terraform\modules\eks
  • eks.fargate in .terraform\modules\eks\modules\fargate
  • eks.node_groups in .terraform\modules\eks\modules\node_groups

Initializing the backend...

Initializing provider plugins...

  • Finding hashicorp/local versions matching ">= 1.4.0, 2.0.0"...
  • Finding hashicorp/null versions matching "3.0.0"...
  • Finding hashicorp/template versions matching "2.2.0"...
  • Finding hashicorp/kubernetes versions matching ">= 1.11.1, >= 2.0.1"...
  • Finding latest version of hashicorp/eks...
  • Finding hashicorp/aws versions matching ">= 3.40.0, >= 3.43.0, 3.43.0"...
  • Finding hashicorp/random versions matching "3.0.0"...
  • Finding terraform-aws-modules/http versions matching ">= 2.4.1"...
  • Finding latest version of hashicorp/cloudinit...
  • Installing hashicorp/local v2.0.0...
  • Installed hashicorp/local v2.0.0 (signed by HashiCorp)
  • Installing hashicorp/null v3.0.0...
  • Installed hashicorp/null v3.0.0 (signed by HashiCorp)
  • Installing hashicorp/template v2.2.0...
  • Installed hashicorp/template v2.2.0 (signed by HashiCorp)
  • Installing hashicorp/kubernetes v2.3.2...
  • Installed hashicorp/kubernetes v2.3.2 (signed by HashiCorp)
  • Installing hashicorp/aws v3.43.0...
  • Installed hashicorp/aws v3.43.0 (signed by HashiCorp)
  • Installing hashicorp/random v3.0.0...
  • Installed hashicorp/random v3.0.0 (signed by HashiCorp)
  • Installing terraform-aws-modules/http v2.4.1...
  • Installed terraform-aws-modules/http v2.4.1 (self-signed, key ID B2C1C0641B6B0EB7)
  • Installing hashicorp/cloudinit v2.2.0...
  • Installed hashicorp/cloudinit v2.2.0 (signed by HashiCorp)

Partner and community providers are signed by their developers. If you'd like to know more about provider signing, you can read about it here: https://www.terraform.io/docs/cli/plugins/signing.html

Error: Failed to query available provider packages Could not retrieve the list of available versions for provider hashicorp/eks: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/eks

All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on hashicorp/eks, run the following command:terraform providers

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/kubernetes] >= 2.0.1
├── provider[registry.terraform.io/hashicorp/aws] 3.43.0
├── provider[registry.terraform.io/hashicorp/random] 3.0.0
├── provider[registry.terraform.io/hashicorp/local] 2.0.0
├── provider[registry.terraform.io/hashicorp/eks]
├── provider[registry.terraform.io/hashicorp/null] 3.0.0
├── provider[registry.terraform.io/hashicorp/template] 2.2.0
└── module.eks
    ├── provider[registry.terraform.io/hashicorp/aws] >= 3.40.0
    ├── provider[registry.terraform.io/hashicorp/local] >= 1.4.0
    ├── provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
    ├── provider[registry.terraform.io/terraform-aws-modules/http] >= 2.4.1
    ├── module.fargate
    │   └── provider[registry.terraform.io/hashicorp/aws] >= 3.40.0
    └── module.node_groups
        ├── provider[registry.terraform.io/hashicorp/aws] >= 3.43.0
        └── provider[registry.terraform.io/hashicorp/cloudinit]

here is my versions file

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.43.0"
    }

    random = {
      source  = "hashicorp/random"
      version = "3.0.0"
    }

    local = {
      source  = "hashicorp/local"
      version = "2.0.0"
    }

    null = {
      source  = "hashicorp/null"
      version = "3.0.0"
    }

    template = {
      source  = "hashicorp/template"
      version = "2.2.0"
    }

    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = ">= 2.0.1"
    }
  }

  required_version = ">= 1.0"
}

1 Answers

Validate the names of your resources... this happened to me, and I spend a reasonable amount of time trying to figure it out. In the end, it was a silly mistake.

In your case, the resource's name in your data blocks must be aws_eks_cluster, and you have eks_cluster. That is it.

Related