Link Search Menu Expand Document

Tools For Refactoring Terraform

Grep

Usually in the form of git grep or an IDE search function. Useful for scanning a codebase for references when considering a rename or other change. In the case of cross-repo dependencies, consider an org-wide GitHub search or equivalent.

Built in

  • terraform plan - Confirm a change is non-disruptive with an empty plan
  • terraform state mv
  • Moved blocks introduced in Terraform 1.1
  • terraform import - Bring an unmanaged resource into your terraform state. Useful for legacy infrastructure or transferring from one state to another.
  • terraform validate
  • terraform fmt - Format code according to Hashicorp standard.
  • local state - Useful for trying out state operations before applying.
  • provider documentation - In addition to resource arguments, resource attributes and data sources are also useful.

Migration support

tfmigrate is a Terraform state migration tool for GitOps.

Static checks

  • tflint - Linter checking for possible issues including errors, deprecated syntax, and naming conventions
  • tfsec - Security scanner for your Terraform code

Testing

tdd-infrastructure is a compilation of terraform testing tools and examples.