Terraform 1.4 introduced a small but important addition to the language: the terraform_data resource.
At first glance it looks simple. It stores values in Terraform state. But its real role is deeper. It allows plain values to participate in Terraform’s lifecycle graph.
Terraform lifecycle rules operate on resource actions, not variables. That means a variable change by itself cannot trigger lifecycle behavior like replace_triggered_by. The terraform_data resource solves this boundary.
Think of terraform_data as a translator.
It converts a human change such as updating a variable into machine language, which is a resource lifecycle event Terraform can observe.
This mechanism enables patterns such as:
- Triggering infrastructure replacement when a version number changes
- Anchoring provisioners without creating fake infrastructure
- Converting logical signals into lifecycle actions
The resource also replaces the older null_resource pattern. In earlier Terraform versions, engineers used null_resource to host provisioners or lifecycle triggers, which required installing the external null provider. The terraform_data resource is built directly into Terraform core, which keeps configurations cleaner and reduces provider dependencies.
Understanding this pattern is useful when designing predictable lifecycle behavior in Terraform, especially when infrastructure changes need to follow application versioning or deployment signals.
Watch the full lesson:

