A production RDS instance must never be accidentally deleted via `terraform destroy`. Which lifecycle setting enforces this?

Direct Answer (Verified)Reviewed by Sunny (Senior Cloud Engineer)

Correct Answer: `prevent_destroy = true` inside a `lifecycle` block

`prevent_destroy = true` in a Terraform `lifecycle` block causes `terraform destroy` (or any plan that would destroy the resource) to return an error. This is a Terraform-level gua...

Real Exam Scenario

A production RDS instance must never be accidentally deleted via `terraform destroy`. Which lifecycle setting enforces this?

✓ Correct Answer & Explanation

Correct Answer

`prevent_destroy = true` inside a `lifecycle` block

Why This Answer Is Correct

`prevent_destroy = true` in a Terraform `lifecycle` block causes `terraform destroy` (or any plan that would destroy the resource) to return an error. This is a Terraform-level guard independent of cloud provider settings. `deletion_protection` on the RDS resource prevents the cloud API call but doesn't stop Terraform from attempting it. Both can be combined for defense-in-depth.