Home

Awesome

tfadd

Generate valid Terraform configuration from state.

Install

go install github.com/magodo/tfadd@latest

Intro

The goal of this tool is to improve the import experience of Terraform, that rather than constructing the configurations from scratch, tfadd (try its best to) provide users a valid configuration automatically.

The valid here means the generated configuration should raise no error and show no diff during terraform plan.

Currently to generate the state, the tool supports full mode (with -full) or partial mode (by default).

Usage

The typical usage is to use tfadd together with terraform import:

  1. Prepare an empty workspace (e.g. an empty directory for local backend)
  2. Identify the existing resources to import, write down the empty resource block
  3. (partial mode only) Run tfadd init [providers...] > terraform.tf to populate the Terraform setting to pin the provider version
  4. Run terraform init to initialize the providers
  5. Import the resources via terraform import
  6. Run tfadd state or tfadd state -full to generate the configuration

Limitation