I am in a dilenma with this error--Failed to query available provider packages

I am getting the error message below when I use the command “terraform init”:

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/user: provider registry registry.terraform.io does not have a provider
│ named registry.terraform.io/hashicorp/user
│
│ 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/user, run the following command:
│     terraform providers

I honestly don’t know where the hashicorp/user is coming from, the only required providers i have in my main.tf is below, i don’t know why its bringing up hashicorp/user instead only hashicorp/aws:

terraform {
  backend "s3" {
    bucket         = "terraform-cloud-challenge-state-bucket"
    key            = "global/s3/terraform.tfstate"
    region         = "eu-north-1"
    #encrypt        = true
    #dynamodb_table = "terraform-cloud-challenge-state-lock"
  }
}

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "5.22.0"
    }
  }
}

provider "aws" {
    region = "eu-north-1"
}

Please help!

Hi @TomiwaAribisala-git,

For backward compatibility with modules written for much older versions of Terraform, terraform init will guess that any resource whose type doesn’t start with a prefix that matches one of the explicitly-declared providers was intended to be a provider in the hashicorp namespace. (Older versions of Terraform didn’t have separate namespaces for providers at all, and most of the providers in the old “flat” naming scheme ended up in the hashicorp namespace.)

Given that, I’m guessing that somewhere in your configuration you have a declaration like this:

resource "user" "example" {

}

whereas you probably intended to write this:

resource "aws_iam_user" "example" {

}

Since there is no entry for user in your required_providers block, Terraform guesses that you intended to declare user = { source = "hashicorp/user" } and then tries to install that provider.

I would suggest searching your configuration for the sequence resource "user (closing quote intentionally omitted) to find any declarations you have where the resource type starts with “user”.