CLI tool to rename Terraform resources, data sources, and modules while automatically generating moved blocks.
tfmv is a CLI tool that automates the renaming of Terraform resources, data sources, and modules. It updates all references in your configuration files and generates the necessary `moved` blocks to maintain state consistency, eliminating manual and error-prone refactoring.
Terraform users and DevOps engineers who need to refactor infrastructure code, such as renaming resources after design changes or standardizing naming conventions across projects.
Developers choose tfmv because it automates a tedious and risky part of Terraform management, ensuring renames are applied consistently and state is preserved without breaking existing infrastructure.
CLI to rename Terraform resources and generate moved blocks
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
It automatically updates all references to renamed resources in Terraform files, as shown in the example where data source dependencies are corrected without manual editing.
Generates moved blocks to maintain state consistency, eliminating the need for manual state refactoring and preventing resource recreation, as demonstrated in the moved.tf output.
Supports simple string replacement, regular expressions, and Jsonnet for complex logic, allowing precise control over renaming, such as using regex to remove suffixes.
The --dry-run flag lets users preview changes without applying them, reducing the risk of errors during refactoring, which is highlighted in the README.
Can process Terraform files recursively across directories, making it suitable for large projects with nested configurations, while ignoring common directories like .git and .terraform.
For advanced renaming, users must write Jsonnet scripts, which adds complexity and requires learning a new configuration language, potentially slowing down adoption for simple tasks.
Once changes are applied, there's no way to revert them within tfmv; users must rely on version control systems like git, increasing the risk if mistakes are made.
It only works with Terraform files and might not handle all HCL syntax variations or custom constructs, potentially leading to parsing errors or incomplete renames.
Lacks a graphical user interface or IDE integration, which might be less convenient for teams preferring visual tools or automated workflows outside the command line.