kbst / terraform-provider-kustomization

Terraform provider for Kustomize
https://www.kubestack.com
Apache License 2.0
267 stars 53 forks source link

Don't fail with "resource already exists" if applying kustomization on resources not otherwise in Terraform's state? #212

Closed ivanov-slk closed 1 year ago

ivanov-slk commented 1 year ago

Hello,

not sure if this is the right place to ask this...

I have a kubernetes resource (a deployment, say) that is already deployed without Terraform for one reason or another (e.g. manually). I want to terraform apply some modifications to that existing deployment without having to first delete the resource manually (e.g. kubectl delete deployment my-svc.

When I run terraform apply I'm getting Error: github.com/kbst/terraform-provider-kustomize/kustomize.kustomizationResourceCreate: deployments.apps "my-svc" already exists.

Is this the desired behavior? Is there a way to configure Terraform's behavior in such cases, like allowing overwriting (potential destroy+apply) of such resources that already exist?

Thank you!

pst commented 1 year ago

Terraform requires the resource to exist in state. Instead of deleting and then creating it from Terraform, you can also use terraform import.