Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
/ tfmigrator Public archive

CLI tool to migrate Terraform configuration and State

License

Notifications You must be signed in to change notification settings

suzuki-shunsuke/tfmigrator

Repository files navigation

tfmigrator

Build Status Go Report Card GitHub last commit License

CLI to migrate Terraform configuration and State

⚠️ Deprecated: Use tfmigrator/tfmigrator and tfmigrator/cli instead of this

Blog written in Japanese

terraformer で雑に生成した tf ファイル と state を分割したくてツールを書いた

Overview

tfmigrator is a CLI tool to migrate Terraform configuration and State into multiple states. tfmigrator configures rules to classify resources and migrate resources to other states via terraform state mv and hcledit.

Requirement

Install

Download a binary from the release page.

How to use

$ vi tfmigrator.yaml
$ cat *.tf | tfmigrator run [-skip-state]

Configuration file

CONFIGURATION.md

example of tfmigrator.yaml

items:
- rule: |
    "name" not in Values
  exclude: true
- rule: |
    Values.name contains "foo"
  state_out: foo/terraform.tfstate
  resource_name: "{{.Values.name}}"
  tf_path: foo/resource.tf
- rule: |
    Values.name contains "bar"
  state_out: bar/terraform.tfstate
  resource_name: "{{.Values.name}}"
  tf_path: bar/resource.tf

Restriction

tfmigrator migrates Terraform configuration with hcledit and doesn't support to expand the expression. For example, if Terraform configuration refers local values, the migrated configuration may be broken.

LICENSE

MIT