Automatically generates Terraform moved blocks and state move commands for safe infrastructure code refactoring.
tfautomv is a command-line tool that automates the generation of Terraform `moved` blocks and state move commands. It solves the problem of Terraform losing track of resource state during code refactoring (like renaming resources or moving them between modules), which would otherwise cause plans to delete and recreate infrastructure unnecessarily.
Terraform, OpenTofu, or Terragrunt users who need to refactor their infrastructure code safely, particularly DevOps engineers, platform teams, and infrastructure developers managing complex Terraform codebases.
Developers choose tfautomv because it eliminates the manual, error-prone process of writing `moved` blocks or state move commands. It automatically detects moves by analyzing plan output, supports advanced use cases like multi-directory moves, and integrates seamlessly into CI/CD workflows, making refactoring faster and safer.
Generate Terraform moved blocks automatically for painless refactoring
Analyzes Terraform plan output to identify creation/deletion pairs from refactoring, eliminating the manual error-prone process of writing moved blocks or state commands.
Generates either Terraform moved blocks (for v1.1+) or terraform state mv commands for cross-directory moves, as detailed in the core features, catering to different workflow needs.
Can analyze multiple Terraform modules in a single run to find moves across directories, a feature Terraform doesn't natively support, making it ideal for large codebases.
Supports pre-generated plan files with the --preplanned flag, allowing seamless integration into enterprise pipelines without re-running expensive terraform plans.
As emphasized in the best practices, it's ineffective for mixed changes where refactoring is combined with infrastructure updates, requiring a strict separation of structural and configuration changes.
The --ignore flag, while useful for provider quirks, can lead to incorrect resource matches if misused, as warned in the documentation, adding complexity and potential for errors.
For moves across different directories, it only outputs state mv commands instead of moved blocks, which may require additional manual steps and isn't as elegant for some Terraform workflows.
CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Cloud cost estimates for Terraform in pull requests💰📉 Shift FinOps Left!
Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
Terraform Pull Request Automation
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.