Terraform: Failed to query available provider packages (aws)

Created on 21 Aug 2020  ·  2Comments  ·  Source: hashicorp/terraform

I followed the explanations here to have the plugins installed only once so no need to download them each time,
I created the folder structure as explained:

ls  /usr/lib/plugins/registry.terraform.io/hashicorp/aws/3.0.0/linux_amd64
terraform-provider-aws_v3.0.0_x5

but still, init throwing the failed to query error:

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider -/aws: provider
registry.terraform.io/-/aws was not found in any of the search locations
- /usr/lib/plugins
# versions.tf
terraform {
  required_version = ">= 0.13"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.0.0"
    }
  }
}

Terraform Version

Terraform v0.13.0

bug working as designed

Most helpful comment

I think the underlying issue here is probably that you have resources in a < 0.13 state file using the aws provider, which results in the need to install a -/aws provider to allow the state file to be migrated. You can verify this by running terraform providers.

If so, there are a couple of ways forward:

  • You can temporarily duplicate the hashicorp folder of your local provider mirror to -. That is, you'd have a directory /usr/lib/plugins/registry.terraform.io/-/aws/3.0.0/linux_amd64 with the same contents as the hashicorp/aws/… directory. This will allow you to run terraform apply (with no changes) to migrate the state file.
  • Alternatively, you can use terraform state replace-provider -- -/aws hashicorp/aws to update your state file manually.

Note that both of these fixes will require you to be ready to upgrade to 0.13, and once your migration is complete you cannot easily roll back to 0.12. Hope this clears things up!

Since I think this is working as intended, I'm going to close this report. Please let me know if this doesn't explain the issue you're seeing and we can reopen if it is a bug.

See also: #25819

All 2 comments

I think the underlying issue here is probably that you have resources in a < 0.13 state file using the aws provider, which results in the need to install a -/aws provider to allow the state file to be migrated. You can verify this by running terraform providers.

If so, there are a couple of ways forward:

  • You can temporarily duplicate the hashicorp folder of your local provider mirror to -. That is, you'd have a directory /usr/lib/plugins/registry.terraform.io/-/aws/3.0.0/linux_amd64 with the same contents as the hashicorp/aws/… directory. This will allow you to run terraform apply (with no changes) to migrate the state file.
  • Alternatively, you can use terraform state replace-provider -- -/aws hashicorp/aws to update your state file manually.

Note that both of these fixes will require you to be ready to upgrade to 0.13, and once your migration is complete you cannot easily roll back to 0.12. Hope this clears things up!

Since I think this is working as intended, I'm going to close this report. Please let me know if this doesn't explain the issue you're seeing and we can reopen if it is a bug.

See also: #25819

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings