GalleyBytes / terraform-operator

A Kubernetes CRD to handle terraform operations
http://tf.galleybytes.com
Apache License 2.0
364 stars 47 forks source link

Clarify role of `ignoreDelete: true` vs `applyOnDelete: false` #29

Open asaintsever opened 3 years ago

asaintsever commented 3 years ago

Hi,

I am currently testing the operator and I must say that I still struggle to understand the role of the ignoreDelete attribute. By reading the documentation, it looks like that, if I don't want to trigger a terraform -destroy, I should either omit applyOnDelete or set applyOnDelete: false. So I fail to understand why we need another attribute to handle deletion behavior. For e.g., does it make sense to set both applyOnDelete: false and ignoreDelete: true? I would say no (without reading the code in details).

Maybe it is only a naming and description issue but thanks for making it clearer.

isaaguilar commented 3 years ago

Thanks for your patience. I just got back from a road-trip across the US.

I will update documentation but basically if ignoreDelete is not set as true, when deleting the terraform resource, the Terraform-operator controller will always spin up a destroy job. Then it's up to applyOnDelete to be set to true to automatically run the destroy command.

What happens if applyOnDelete is set to false, the terraform-runner pod will do a destroy-plan, and then wait. See what happens when applyOnDelete is false here: https://github.com/isaaguilar/terraform-operator/blob/master/docs/operator-actions.md#when-apply-is-false.

Finally, the reason that ignoreDelete isn't automatically set as true when applyOnDelete is false is exactly for that case when a user wants to "pause" after a plan and not automatically run the destroy command.

This was a concept I had when originally creating the operator that might be able to hook into another system that can manage the plan/apply.

I hope this helps, but I'll try to document this so it's not as ambiguous.