Got myself in a wonky state after upgrade

Not really sure what I did wrong (or if I can back it out) but I attempted to update terraform

Terraform v0.12.2
+ provider.google v2.9.0
+ provider.helm v0.10.0
+ provider.k8s (unversioned)
+ provider.kubernetes v1.7.0
+ provider.null v2.1.2
+ provider.template v2.1.2

I did this by installing the new binaries and running “terraform 0.12upgrade”. Now when I run terraform apply i get the error:

Error: Failed to instantiate provider “k8s” to obtain schema: Incompatible API version with plugin. Plugin version: 4, Client versions: [5]

Clearly I have an issue with the “provider.k8s (unversioned)”. This provider is using “https://github.com/ericchiang/terraform-provider-k8s” to apply CRDs (Certificate) int kubernetes. I chose this route because it didn’t look like terraform supported CRDs.

Unfortunately, now I am sort of stuck. Can I roll back to 11? Can I make it work in 12? What is the best way to manage CRD’s in version 12?

Thank you very much

switching my provider over to here seemed to work…

Hi @mornindew,

It sounds like you got it to work by upgrading the provider, but I’ll add some extra context for anyone else who finds this in future:

Third-party Terraform providers (like this k8s provider) are not automatically installed and upgraded by Terraform, so if you are using any such providers then when upgrading to Terraform 0.12.x you need to also manually upgrade the provider to a newer version that supports the Terraform 0.12.x provider protocol.

This error is reporting that the provider supports only protocol version 4, but Terraform 0.12.x requires provider version 5. This error message is normally better for plugins that Terraform is able to install itself from the registry, because Terraform has more information from the registry API to figure out what’s going on, but it falls back on a generic error message for locally-installed plugins.

As long as you haven’t run terraform apply or any of the other commands that modify persisted state (e.g. the terraform state subcommands) then rolling back should be fine. Once Terraform 0.12 has written a new state snapshot during apply, downgrading is unfortunately no longer possible because the persisted state snapshot will then be in the v0.12.x file format.

If you run terraform 0.12checklist on Terraform 0.11.14 prior to upgrading, as recommended by the upgrade guide, it should give you a heads-up that you are using providers that are not v0.12.x-compatible so that you can potentially upgrade those first before upgrading to Terraform v0.12.x. There’s no harm in doing all of these upgrades together in a single step if you like, but the checklist command is there in case you want to move in smaller steps by getting the providers upgraded and working with Terraform v0.11.14 first.