Issues with terraform init if iam resourses used

I have some files using iam resources, a simple
resource “aws_iam_role” and when I do a terraform init, I get:

Initializing provider plugins…

  • Finding hashicorp/iam versions matching “3.52.0”…
  • Reusing previous version of hashicorp/aws from the dependency lock file
  • Reusing previous version of hashicorp/template from the dependency lock file
  • Using previously-installed hashicorp/aws v3.74.0
  • Using previously-installed hashicorp/template v2.2.0

    │ Error: Failed to query available provider packages

    │ Could not retrieve the list of available versions for provider hashicorp/iam: provider registry does not have a provider named Terraform Registry

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

Usually this error is raised if the resources are not properly named. Meaning instead of aws_iam_role something like iam_role was used.

unfortunately is not the case:

resource “aws_iam_role”


resource “aws_iam_policy” “policy_one”

resource “aws_iam_policy” “policy_two”

even using this example:

Terraform Registry does not properlly, i get the same issue.

Hi @jpor1974,

@tbugfinder is right that a common cause of this error is to type a resource type name incorrectly and thus make Terraform think you are trying to activate the legacy behavior of auto-detecting provider dependencies by the prefixes of resource type names.

However, in your case the output has an extra clue which suggests that something different is happening:

Finding hashicorp/iam versions matching "3.52.0"…

An automatically-inferred provider requirement would not have a specific version constraint like this, and would instead just select the latest available version of the provider. The fact that there’s a specific version constraint here suggests that this requirement is actually declared in your configuration somewhere.

Fortunately this seems to be the only mention of the specific version number 3.52.0 in the set of version numbers mentioned, so maybe you’ll be able to find it by searching your codebase for that version string.

I’m expecting you’ll find something shaped like one of the following examples:

# legacy provider version constraint syntax
provider "iam" {
  version = "3.52.0"
# v0.12-style provider requirement shorthand syntax
terraform {
  required_providers {
    iam = "3.52.0"
# modern provider requirement syntax
terraform {
  required_providers {
    iam = {
      version = "3.52.0"

In each of these cases I think the solution would be to remove the errant requirement, since you aren’t intending to use a provider named “iam”.

If you can’t find any such reference then I’m not sure what else to suggest. :confused:

Was my mistake, thanks a lot