gavinbunney / terraform-provider-kubectl

Terraform provider to handle raw kubernetes manifest yaml files
https://registry.terraform.io/providers/gavinbunney/kubectl
Mozilla Public License 2.0
619 stars 105 forks source link

Handling of older apiversion causes failure when components upgraded #156

Closed MatthewFagan closed 2 years ago

MatthewFagan commented 2 years ago

Hi. We are using cert-manager with custom records added using your plugin. Our terraform deployed "apiVersion: cert-manager.io/v1alpha2". When we upgraded cert-manager on the cluster, it automatically changed the deployed apiVersion to "apiVersion: cert-manager.io/v1", so everything should be ok. However, when we run terraform, your plugin reads the "apiVersion: cert-manager.io/v1alpha2" from terraform state and then gets an error that it is an unsupported version.

Error: failed to create kubernetes rest client for read of resource: resource [cert-manager.io/v1alpha2/ClusterIssuer] isn't valid for cluster, check the APIVersion and Kind fields are valid

We also tried modifying the apiversion in the terraform script before upgrading cert-manager, and that gave us a different error.

Error: Provider produced inconsistent result after apply When applying changes to module.cert-manager.kubectl_manifest.cluster_issuer, provider "provider[\"registry.terraform.io/gavinbunney/kubectl\"]" produced an unexpected new value: Root resource was present, but now absent.

Is there a way to fix this so it can recognize api version changes?

MatthewFagan commented 2 years ago

OK, so it turns out we are using an older version. The latest version fixes the issue.