-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace null_resource with terraform_data #1548
base: master
Are you sure you want to change the base?
Replace null_resource with terraform_data #1548
Conversation
terraform_data suggested instead of null_resource as from Terraform 1.4. See https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource.
@janfrederik Your issue has been accepted last week, so great job! Going to review in-depth. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
Overall, this PR cleanly replaces null_resource
with the new terraform_data
resource. The approach is consistent throughout, using triggers_replace
to force a new evaluation when relevant data changes. The added moved
blocks ensure a smooth migration of state, and the mapping from null_resource
to terraform_data
looks thoughtfully handled.
Key Observations
terraform_data
Resource Semantics: Theterraform_data
resource is designed for ephemeral data or orchestration placeholders. Using it as a direct replacement fornull_resource
is valid, and the usage looks consistent with typical patterns of triggers and provisioning logic.- State & Orchestration: You are storing some relatively large sets of triggers (like checksums) in
yamlencode(...)
. That is typical fornull_resource
migrations but keep in mind that changes in large dynamic strings can lead to more frequent replacements. This is expected, but be sure that is the intended orchestration flow. - Use of Moved Blocks: Excellent approach to preserve state (
moved { from = null_resource.foo to = terraform_data.foo }
) so existing resources do not get recreated inadvertently. - No Obvious Performance or Security Gaps: The code remains consistent with prior state. The references to sets, triggers, and inline provisioning look properly aligned.
Recommendation: The changes look good overall. Great work on systematically replacing these resources!
I'm ready to merge when you are, let me know @janfrederik |
Hi @mysticaltech Still waiting for the release of opentofu 1.10 with the support for moving |
Ok wonderful, thanks |
As from Terraform 1.4, the doc suggests to use
terraform_data
instead ofnull_resource
. See https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource.To avoid destroy and recreation of these resources, terraform>=1.9 allows the
moved
statement to do exactly this refactoring. Works like a charm :-)For details, see https://registry.terraform.io/providers/hashicorp/null/latest/docs/guides/terraform-migration#migrating-existing-configurations.