Hi, I installed Terraform v0.14.10 and tried to initialize. 2 errors were thrown:
“Invalid legacy provider address”
each for ‘template’ and ‘external’.
This is the output of the ‘terraform providers’ command:
Providers required by configuration:
.
├── provider[terraform.io/builtin/terraform]
├── provider[Terraform Registry]
├── provider[Terraform Registry]
├── provider[Terraform Registry]
├── module.sfn-call-ingest-mws
│ └── provider[Terraform Registry]
├── module.sfn-ingest-mws
│ └── provider[Terraform Registry]
├── module.sfn-auto-forecast
│ └── provider[Terraform Registry]
└── module.sfn-call-auto-forecast
└── provider[Terraform Registry]
Providers required by state:
provider[registry.terraform.io/-/external]
provider[registry.terraform.io/-/template]
provider[registry.terraform.io/hashicorp/aws]
provider[terraform.io/builtin/terraform]
What should I do to be able to successfully run the ‘terraform init’ command?
Hi @simongillett,
Based on that terraform providers
output it seems like you are in the process of upgrading from an earlier Terraform version. This sort of legacy provider address is typically resolved during the upgrade to v0.13, so I’m surprised to still see those addresses remaining now you’re upgrading to v0.14.
Terraform v0.13 has some mechanisms to automatically upgrade these as you use it, but if your goal is to just get to v0.14 with as little ceremony as possible then for this configuration (which is using only “official” providers, and therefore is a relatively easy case) you should be able to get this fixed up by using one of the Terraform v0.13 releases to run the following commands:
terraform state replace-provider "registry.terraform.io/-/external" "registry.terraform.io/hashicorp/external"
terraform state replace-provider "registry.terraform.io/-/template" "registry.terraform.io/hashicorp/template"
This should then replace the two “legacy” (non-namespaced) provider source addresses in your state with the new namespaced style, and then Terraform v0.14 should accept the state as valid.
(Note for others who might find this comment in future: this advice doesn’t apply exactly as I wrote it for non-official providers that are outside of the “hashicorp” namespace. For those, it’s worth reading through the v0.13 upgrade guide for some additional important considerations.)
2 Likes
Thhank you for that @apparentlymart . I have a similar error with terraform providers, this time the error is thrown by:
provider[registry.terraform.io/-/local]
Is the solution going to be:
terraform state replace-provider "registry.terraform.io/-/local" "registry.terraform.io/hashicorp/local"
?
I just want to be sure before committing.
By the way, I skipped v0.13!
Hi @simongillett,
The local
provider also belongs to the hashicorp
namespace in the new setup, so indeed that command line should work there too.
As a more general answer to this question, if you run terraform init
with v0.13 then it should print out some hints about the different situations discussed in the upgrade guide. It uses a special API to ask the Terraform Registry which namespaces previously-available providers ended up belonging to, or to recognize providers that were not previously auto-installable at all, and so it can give more feedback than Terraform v0.14 can. (Terraform v0.14 no longer contains those migration helpers because the upgrade process assumes you’ll go only one major version at a time.)
1 Like