Skip to content

no-terraform-data-condition

Disallow lifecycle conditions attached to terraform_data guard resources.

Why

A terraform_data resource created only to reject a plan turns configuration policy into stateful graph noise. The assertion drifts with today's configuration while obscuring the input, resource, test, or deployment boundary that owns the invariant.

Fix

Delete the terraform_data guard. Put an input invariant on its variable, a provider invariant on the owning resource, and environment or rollout policy in tests and deployment review.

Examples

Before — flagged Do not model deployment policy as a fake resource
main.tf
resource "terraform_data" "deployment_guard" {
lifecycle {
precondition {
condition = var.enabled
error_message = "deployment must be enabled"
}
}
}
After — preferred Keep terraform_data when it models replacement
main.tf
resource "terraform_data" "release" {
triggers_replace = [var.release]
}