Yoav Berneman
Yoav Berneman

Reputation: 1

provider error new hashicorp/get provider

terraform plan causes:

Error: Inconsistent dependency lock file

The following dependency selections recorded in the lock file are inconsistent with the current configuration: provider registry.terraform.io/hashicorp/get: required by this configuration but no version is selected

To update the locked dependency selections to match a changed configuration, run: terraform init -upgrade

running terraform init -upgrade gives this error:

Error: Failed to query available provider packages

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

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/get, run the following command: terraform providers

terraform providers gives

provider[registry.terraform.io/hashicorp/get] as one of the providers

What is this provider, and why did it suddenly show up? Is this a wide hashicorp bug?

I followed the terraform prompts in the console with no success. Hope you can help

Fixed It was my fault, the reason was this:

data "get_caller_identity" "current" {}

insted of:

data "aws_caller_identity" "current" {}

Upvotes: 0

Views: 107

Answers (1)

Martin Atkins
Martin Atkins

Reputation: 74594

For backward-compatibility with much older versions of Terraform that didn't yet support automatic installation of third-party providers, Terraform has some heuristics to guess what you meant when you don't declare a provider dependency in your required_providers block:

  • Any resource block which doesn't have a provider block selects the default instance of whichever provider has the local name matching the first part of the resource type name, up to the first underscore.
  • If any resource is associated with a provider local name that isn't declared in a required_providers block, Terraform guesses that you intended to use a hashicorp/-namespaced provider with that name because that is how older versions of Terraform (before there were any namespaces at all) would've behaved.

You have written data "get_caller_identity" "current" {}, and so:

  1. Terraform notices that there is no provider argument in this block, and so takes the get prefix from your resource type name and assumes you intended to write provider = get.
  2. There is no get entry in your module's required_providers block, and so Terraform assumes you are trying to use hashicorp/get.

I'm guessing you probably intended to use the aws_caller_identity data source from the hashicorp/aws provider. In that case you will need to spell its type name correctly in your data block:

data "aws_caller_identity" "current" {}

Then the heuristics will work properly:

  1. There is no provider argument, and the resource type name starts with "aws", so Terraform assumes provider = aws.
  2. The required_providers block does not include an entry with the local name aws, and so Terraform guesses that you meant hashicorp/aws.

Upvotes: 0

Related Questions