Issue upgrading from 0.12 to 0.13 with provider present in registry

I am upgrading a repository from 0.12.24 to 0.13.5 as an intermediate step towards upgrading to 0.14.

The full list of steps I’m taking is as follows:

  • Empty ~/.terraform.d/plugins folder
  • cd to repo
  • Delete .terraform folder
  • Set terraform version to 13.5
  • Set new provider:
terraform {
   required_version = "0.13.5"
   required_providers {
      contentful = {
         source = "labd/contentful"
         version = "0.1.0"
      }
   }
}
  • tfenv use 0.13.5
  • terraform 0.13upgrade
  • terraform state replace-provider registry.terraform.io/-/contentful registry.terraform.io/labd/contentful
  • terraform init

This leads to the following error:

Initializing modules…
- contenttypes in terraform/contenttypes
Initializing the backend…
Initializing provider plugins…
- Finding labd/contentful versions matching “0.1.0”…
- Finding latest version of hashicorp/contentful…
- Installing labd/contentful v0.1.0…
- Installed labd/contentful v0.1.0 (self-signed, key ID 34F8AEB5E494DDA9)Partner and community providers are signed by their developers.
If you’d like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/plugins/signing.htmlError:
Failed to install provider
Error while installing hashicorp/contentful: provider registry
registry.terraform.io does not have a provider named
Terraform Registry

I am unsure why it is trying to find it in hashicorp/contentful. I checked the upgrade guide but that only seems to suggest such errors can occur when the provider is not in the registry. The provider in question is in the registry though at Terraform Registry

Can anyone see what I am missing to make this upgrade work?

Any help and all help would be much appreciated.

And of course 30 minutes after you finally decide to make a post you find the solution. For any people who run into similar problems in the future:

Make sure all your modules also have a versions.tf file with the right releases set for all providers as well as the main terraform config.

1 Like