Immutability in Terraform exists to prevent that. When you make infrastructure immutable, you never change resources in place. You replace them. The old state is destroyed only after the new one is proven ready. This eliminates configuration drift, reduces hidden dependencies, and ensures that every change is deliberate and reproducible.
Terraform’s declarative approach pairs naturally with immutability. The .tf files describe the exact desired state, not the steps to get there. By enforcing immutability, you guarantee that this state is always the single source of truth. Any deviation—manual edits, ad-hoc hotfixes, side-door changes—will be overwritten on the next apply.
Use versioning aggressively. Pin module versions. Keep your backends and state locked down. When using terraform plan and terraform apply, verify that changes are additive or replace-only. For critical resources, configure lifecycle rules like create_before_destroy to ensure zero downtime. Immutable infrastructure forces visibility: if it changes, it’s in code, reviewed, and versioned.