Terraform Conditional Resource Creation: The Toggle That Destroys

Most engineers think a Terraform feature flag “turns something off.”

It does not.

When you set count = 0 or for_each = {}, Terraform removes that node from the graph. If the resource already exists in state, Terraform plans a destroy. The boolean is not a preference switch. It is an ownership switch.

In this lesson:

  • Why conditional resources are graph decisions, not runtime behavior
  • How to safely reference resources that may not exist
  • Why flipping a flag in production can become a decommission event

If a flagged resource holds state, data, or access control, toggling it off is not cosmetic. It is lifecycle control.

Watch the full lesson here:
👉 Terraform Conditional Resource Creation Explained