Can you upgrade to 0.13 if using a community provider with the 0.12 version file syntax

I’ve started the upgrade process to 0.13.2 and later saw that we use the terraform-aws-security-group community module that still has the 0.12 syntax of the version.tf file. Do I have any options other than waiting or downgrading Terraform. Thank you.

What do you mean by “the 0.12 syntax of the version.tf file”? From the version on the main branch of the GitHub repository it looks like this module should work fine with Terraform 0.13: a constraint of >= 0.12, < 0.14 should work.

Have you tried the upgrade and hit an error?

Yeah, I’ve run into this… I’ve started updating all of our modules following v0-12-compatible-provider-requirements. Then I noticed the community module.

Terraform v0.13.2
Initializing plugins and modules...

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"

Ah, I see. What happens when you run terraform init? And can you also paste the output of terraform providers?

Here you go. This includes all of my recent updates to modules that we own.
terraform_providers.txt (5 KB) terraform_init.txt (6.7 KB)

Here’s the versions.tf file for the workspace

terraform {
  required_version = ">= 0.13"
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
    template = {
      source = "hashicorp/template"
    }
  }
}

Ah, thanks! That’s interesting, it looks like this is a case where the automatic provider upgrading doesn’t quite work. Your state file is requiring the -/aws and -/template providers, and Terraform can’t work out that those should be upgraded to hashicorp/aws and hashicorp/template automatically.

You can work around this using the terraform state replace-provider subcommand. In this case, the following should work:

terraform state replace-provider -- -/aws hashicorp/aws
terraform state replace-provider -- -/template hashicorp/template

Note: running this command will upgrade your state file to 0.13, which is not reversible, so please be sure you’re ready to upgrade.

Please let us know if this works for you! For more details on what’s happening here, see this section of the 0.13 upgrade guide.

That worked. Thank you!

1 Like

This worked for me as well, thank you! I upgraded from TF12 to TF13 for a workspace that is connected to a VCS repo, so I can’t run an apply on my laptop. Running this allowed me to run it TF Cloud again.

terraform state replace-provider -- -/tfe hashicorp/tfe