Cross-State Terraform and OpenTofu Refactoring CLI

dev tool real project •• multiple requests

Terraform's moved blocks handle simple renames within a single state file, but cross-state moves, module extraction across workspaces, and backend migrations still require hours of manual terraform state mv commands with high risk of destroying resources. A 40-module migration that should take 10 minutes routinely becomes a 2-4 hour ordeal.

builder note

The killer feature is the dry-run simulation. Before any state mutation, show exactly which resources will be affected, which dependencies will break, and what the rollback path is. Terraform users are trauma-bonded to state corruption. The trust bar is extremely high. Ship the read-only analyzer first, the mutation tool second.

landscape (4 existing solutions)

Moved blocks solved the easy case (renames within one state). The hard cases remain: splitting monolithic states, extracting modules to separate workspaces, migrating backends (e.g., Terraform Cloud to S3), and coordinating changes across dependent states. No tool provides a dependency-aware dry-run simulation for these operations.

Terraform moved blocks (built-in) Only works within a single state file. Cannot move resources between state files, workspaces, or backends. No cross-module dependency analysis.
terraform-state-mover Interactive CLI wrapper around terraform state mv. Manual process, no dependency graph analysis, no dry-run simulation, no rollback.
tfautomv Automates detecting which resources need moved blocks after a refactor. Helpful but reactive, not proactive. Doesn't handle cross-state scenarios.
Spacelift / Scalr / env0 Managed platforms that abstract state management but require full platform adoption. Overkill for teams that just need safe refactoring.

sources (4)

other https://scalr.com/learning-center/terraform-moved-blocks-ref... "Many in the community still see the moved block as a bit of a kludge" 2026-02-01
other https://www.shuttle.dev/blog/2025/11/13/infrastructure-as-co... "Even a small refactor breaks dependencies or invalidates states" 2025-11-13
other https://tasrieit.com/blog/opentofu-vs-terraform-2026 "37 of 40 modules worked, 3 required manual state migration debugging" 2026-02-15
other https://github.com/mbode/terraform-state-mover "Refactoring Terraform code has never been easier" 2025-06-01
terraformopentofuinfrastructure-as-coderefactoringCLI