Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: Failed to query available provider packages #270

Open
scheung38 opened this issue Dec 19, 2020 · 11 comments
Open

[BUG] Error: Failed to query available provider packages #270

scheung38 opened this issue Dec 19, 2020 · 11 comments

Comments

@scheung38
Copy link

scheung38 commented Dec 19, 2020

Cloned this repo and without changing anything other than providing the Digital Ocean key:

export DIGITALOCEAN_TOKEN='Token from Digital Ocean'

Steps to produce:
cd terraform-provider-rke/examples/digitalocean
terraform init

Warning: Interpolation-only expressions are deprecated

on rke.tf line 64, in resource "rke_cluster" "cluster":
64: addons = "${data.template_file.addons.rendered}"

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider
hashicorp/digitalocean: provider registry registry.terraform.io does not have
a provider named registry.terraform.io/hashicorp/digitalocean

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/rke:
provider registry registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/rke

(.venv) ➜ digitalocean git:(master) terraform --version
Terraform v0.14.2

Mac Big Sur: 11.1

@munro
Copy link

munro commented Dec 24, 2020

I'm getting a similar error

I have

variable "do_token" {}

provider "digitalocean" {
  token = var.do_token
}

then when I run

terraform init

I get

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/digitalocean...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider
hashicorp/digitalocean: provider registry registry.terraform.io does not have
a provider named registry.terraform.io/hashicorp/digitalocean

If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.

Did you intend to use digitalocean/digitalocean? If so, you must specify that
source address in each module which requires that provider. To see which
modules are currently depending on hashicorp/digitalocean, run the following
command:
    terraform providers

@munro
Copy link

munro commented Dec 24, 2020

Oh, I figured it out. @scheung38 try adding this

terraform {
  required_providers {
    digitalocean = {
      source = "digitalocean/digitalocean"
    }
  }
}

@aireddy73
Copy link

aireddy73 commented Feb 3, 2021

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider
hashicorp/digitalocean: provider registry registry.terraform.io does not have
a provider named registry.terraform.io/hashicorp/digitalocean

If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.

Did you intend to use digitalocean/digitalocean? If so, you must specify that
source address in each module which requires that provider. To see which
modules are currently depending on hashicorp/digitalocean, run the following
command:
terraform providers

I am using terraform 14.5 on Windows10

very simple code ..
provider "digitalocean" {
token = "XXXXXXXX"
}

resource "digitalocean_droplet" "mydroplet" {
image = "ubuntu-18-04-x64"
name = "web-1"
region = "sfo2"
size = "s-1vcpu-1gb"
}

@aireddy73
Copy link

It worked after adding below mentioned provider block

terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
}
}
}

@asmasud
Copy link

asmasud commented Feb 4, 2021

Oh, I figured it out. @scheung38 try adding this

terraform {
  required_providers {
    digitalocean = {
      source = "digitalocean/digitalocean"
    }
  }
}

@asmasud
Copy link

asmasud commented Feb 4, 2021

Thanks it worked for me too

@rawmind0
Copy link
Contributor

rawmind0 commented Feb 9, 2021

Provider examples were created to use terraform 0.12.x. They has not been updated yet, to use tf 0.13.x and registry.terraform.io. We've published a guide to update this provider to tf 0.13.x, https://registry.terraform.io/providers/rancher/rke/latest/docs/guides/upgrade_to_0.13 .

As mentioned, this will make the example works

terraform {
  required_providers {
    digitalocean = {
      source = "digitalocean/digitalocean"
      version = "X.Y.Z"
    }
  }
}

Anyway, PR #272 has been submitted to update DO examples. Once reviewed, it would be merged.

@jadamcraig
Copy link

@rawmind0 , Yes, now that you mention it, the issue originally reported by @scheung38 above is actually what started me down the path of working on PR #272 .

I am currently working on a similar example template for Linode. Also, since I'm hearing rumours that RancherOS may soon be abandoned, I'll plan to review the DO example again once DigitalOcean themselves decide which container OS to include in their staff-maintained images. Presently, RancherOS is the only option there, though.

@rawmind0
Copy link
Contributor

@jadamcraig , thanks for working on that PR.

RancherOS may be fine by the moment, but it's arriving to EOL soon, rancher/os#3000 (comment)

@manuelemeka
Copy link

terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
}
}
}

@air3ijai
Copy link

In our case the issue was related to the lack of the required_providers block in the module.

Root module - versions.tf

# Terraform settings
terraform {
  required_version = "~> 1.6"
  required_providers {
    digitalocean = {
      source  = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
  }
}

Child module - modules/doks/versions.tf

# Terraform settings
terraform {
  required_providers {
    digitalocean = {
      source  = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
  }
}

Reference

  1. Using a non hashicorp provider in a module
  2. Why doesn’t required_providers in a child module inherit declarations from the parent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants