terraform-provider-kustomization icon indicating copy to clipboard operation
terraform-provider-kustomization copied to clipboard

apiVersion mismatch between last-applied-configuration and manifest causes silent import failure

Open willthames opened this issue 2 years ago • 1 comments

If you have a resource that appears to be apps/v1 but was last applied with extensions/v1beta1, terraform import fails silently

This came up for me today with a (very old) Deployment but will likely come up again for Ingress

This would be fine if it failed with an error message but it says it imported successfully but terraform state list doesn't have it there.

I suspect that erroring if the lac has a differnt api version to the response resource in https://github.com/kbst/terraform-provider-kustomization/blob/master/kustomize/resource_kustomization.go#L484-L491 might be enough for this edge case

willthames avatar Aug 31 '21 07:08 willthames

I agree it shouldn't fail silently. I'm not sure about the cause. A diff between the apiVersion in the ID given to the import command and what's in the lastAppliedConfig annotation seems most likely to cause this.

Relying on the annotation is generally a problem with the provider. Linking this here to connect the dots to consider for a future refactor. https://github.com/kbst/terraform-provider-kustomization/pull/89

pst avatar Sep 29 '21 13:09 pst

This issue hasn't had any activity in a long time and the code has since been refactored. I'm closing this issue. Should the issue show up again, we can create a new issue.

pst avatar Jan 03 '23 14:01 pst