Error: Failed to install providers

Am getting the below error while running terraform. Can anyone please help to solve on this

Error: Failed to install providers

Could not find required providers, but found possible alternatives:

hashicorp/openstack -> terraform-providers/openstack

If these suggestions look correct, upgrade your configuration with the

following command:

terraform 0.13upgrade modules/broker/base/prod

@vijaytakkoli it looks like you’re using configuration code written for terraform version lower than 0.13, but your current CLI version is 0.13 or greater.

There were introduced several changes to syntax with version upgrade, the reference to providers is the one of them.

The easy way to workaround this: backup your source code and run suggested command terraform 0.13upgrade modules/broker/base/prod. The output will show the files changed and you can browse them to see the difference.

Thanks for your response. I tried by giving terraform 0.13 version in our drone yml file but still it is failing with same error.Apart from running the command which u said , is there any other way to fix this?

I tried by giving terraform 0.13 version in our drone yml file but still it is failing with same error

@vijaytakkoli, this is exactly why you see the error message with suggestion about terraform 0.13upgrade – your Terraform CLI application version is 0.13 or higher. I suppose you have it defined in the drone pipeline configuration or it’s default for your environment.

You might try to specify / use lower version of Terraform CLI (i.e. the latest one from 0.12.x) in your pipeline if you don’t want to change the code. I suggest testing this locally first: install Terraform 0.12.x on your machine and run terraform init, then terraform validate (inside your configuration directory root) to make sure you have the correct match between CLI version and the code.

My previous reply contains the link to documentation which describes your case in details.

Thanks very much. I downloaded 0.13 version and ran terraform 0.13upgrade modules/broker/base/prod which solved the issue

Hey guys,

I have a similar issue where I am trying to use Terraform Registry
With Terraform v0.12.29

And I am hitting the same error

Error: Failed to install providers
Could not find required providers, but found possible alternatives:
hashicorp/newrelic → newrelic/newrelic

I don’t want to upgrade to Terraform 0.13 Is there a way I can still get it working?

Cc: @vasylenko

Hi @deshdeep-airwallex,

For Terraform v0.12 and earlier you can only use providers that are in the old “flat” provider namespace, because Terraform v0.12 doesn’t know how to find and install providers in other namespaces.

Fortunately for your case, the newrelic/newrelic provider is the successor of a provider that used to be published in the old namespace, simply called “newrelic”. So if you omit the v0.13-style provider dependency declaration you can use that provider on Terraform v0.12.

terraform {
  required_providers {
    newrelic = "~> 1.0.0"
  }
}

If you want to use it in shared modules that are in transition from Terraform v0.12 to v0.13 then you can use a recent version of Terraform v0.12 which has support for parsing and then ignoring the Terraform v0.13-style requirements syntax, in which case you could write a declaration like this which will work in both Terraform v0.12 and v0.13:

terraform {
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "~> 1.0.0"
    }
  }
}

This last part, for writing cross-compatible declarations, is covered in more detail under the documentation section v0.12-Compatible Provider Requirements.