Terraform - Error: Could not load plugin v1.0.9

Hello all , I am working on some terraform changes in our repository . The changes is for creating a IAM role . Post making the changes i am getting the below error when trying to do terraform apply. Both the terraform init and terraform plan command works without any issues.

│ Error: Could not load plugin
│
│
│ Plugin reinitialization required. Please run "terraform init".
│
│ Plugins are external binaries that Terraform uses to access and manipulate
│ resources. The configuration provided requires plugins which can't be located,
│ don't satisfy the version constraints, or are otherwise incompatible.
│
│ Terraform automatically discovers provider requirements from your
│ configuration, including providers used in child modules. To see the
│ requirements and constraints, run "terraform providers".
│
│ failed to instantiate provider "registry.terraform.io/-/aws" to obtain schema: unknown provider "registry.terraform.io/-/aws"

Here is the output of my terraform version

terraform --version
Terraform v1.0.9
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v2.70.4

Your version of Terraform is out of date! The latest version
is 1.7.3. You can update by downloading from https://www.terraform.io/downloads.html

Not sure why it is looking for a "registry.terraform.io/-/aws" instead of registry.terraform.io/hashicorp/aws

Hi @shyam2794,

It seems like your current state was created with an older version of Terraform and you haven’t completed the Terraform v0.13 upgrade steps, so your latest state snapshots contain old-style provider references that don’t specify which namespace they belong to.

If your configuration is also still targeting an older version of Terraform then I would suggest following the Terraform v0.13 upgrade steps (in the document I linked above) to also get your configuration updated to the new structure.

If you’re sure that it’s only the state snapshot that needs upgrading, you might instead refer to Why do I see -/provider during init? for a section focused specifically on the symptom you’ve described here, which includes a targeted solution for just that problem.

(That documentation asserts that these legacy addresses “don’t cause a problem for Terraform”, and that was true at the time of the Terraform v0.13 release, but that version of Terraform is now very old and so the automatic upgrade code is no longer present in more recent versions of Terraform, and thus this has become an error.)