Terraform’s prevent_destroy lifecycle setting makes any plan that would destroy its associated resource fail. Enable it with the literal value true inside a resource’s lifecycle block. section 2.7.2
Protecting an instance
A resource can reject destructive plans by declaring lifecycle { prevent_destroy = true }. This may suit logs that must remain for compliance, but it should be used rarely because it obstructs planned destruction. section 2.7.2
The setting accepts only hardcoded values, so it cannot vary between production and development. Removing the resource block also removes the setting, allowing Terraform to destroy the resource. section 2.7.2
For accidental-update protection, consider ignore_changes instead; prevent_destroy is primarily a hard stop against destruction and can hinder temporary environment workflows. section 2.7.2
