Search code examples
terraformupgradeterraform-provider-awsterraform0.12+

Can't upgrade from terraform version 0.13 to 0.14 - Error: Invalid legacy provider address


I am trying to upgrade my terraform version from 0.13.7 to 0.14 but get this error when moving to version 0.14:

Error: Invalid legacy provider address

This configuration or its associated state refers to the unqualified provider
"aws".

You must complete the Terraform 0.13 upgrade process before upgrading to later
versions.

Error: Terraform exited with code 1.
Error: Process completed with exit code 1.

I have tried everything i can find online about this error. I have done:

  • Ran terraform init and apply using terraform v13 successfully
  • ran the "terraform 0.13upgrade" command on my .tf files
  • made sure all modules (even modules within modules etc) have also had the "terraform 0.13upgrade" command ran
  • Ran this command terraform state replace-provider "registry.terraform.io/-/aws" "hashicorp/aws"
  • Double checked the state file and confirmed there is no "registry.terraform.io/-/aws" that exists
  • Ran terraform init -upgrade
  • Remove aws provider version constraints incase there were any old versions that aren't compatible with TF v13
  • Re-ran terraform on 0.13.0 and applied (to see if the version of 13 i used mattered)

What else is the issue? What else can I try?

UPDATE: my required providers block:

terraform {
  required_version = ">= 0.13"
  required_providers {
    archive = {
      source = "hashicorp/archive"
    }
    aws = {
      source = "hashicorp/aws"
    }
    local = {
      source = "hashicorp/local"
    }
    random = {
      source = "hashicorp/random"
    }
    template = {
      source = "hashicorp/template"
    }
    vault = {
      source = "hashicorp/vault"
    }
  }
}


Solution

  • Found the answer on this post

    TL;DR - Have to select workspace in the terraform init command.