Go library to migrate Terraform Configuration and State with terraform state mv
and terraform state rm
command and hcledit.
Using tfmigrator, you can do the following.
- migrate resource address
- e.g.
null_resource.foo
=>null_resource.bar
terraform state mv null_resource.foo null_resource.bar
hcledit block mv -u -f main.tf resource.null_resource.foo resource.null_resource.bar
- e.g.
module.foo
=>module.bar
- e.g.
- move resources in a Terraform Configuration file and State to the other file and State
- e.g.
terraform.tfstate
=>foo/terraform.tfstate
- e.g.
main.tf
=>foo/main.tf
- e.g.
- remove resources from State and Terraform Configuration
- e.g.
terraform state rm null_resource.foo
- e.g.
hcledit block rm -u -f main.tf resource.null_resource.foo
- e.g.
On the other hand, tfmigrator doesn't support the following things.
- change resource fields (attributes and blocks)
- e.g.
hcledit attribute
- e.g.
- Go
- Terraform
hcledit isn't needed.
Please see examples.
https://pkg.go.dev/github.com/tfmigrator/tfmigrator/tfmigrator
The example and README tell us how to use tfmigrator and how tfmigrator works. You can implement a command for migration with Go simply. About the detail of Planner, please see the document of Source and MigratedResource.
QuickRun provides a high level API, so if you use QuickRun, you don't have to know about other API like Runner. But if you need low level API, please check other API like Runner.
We have implemented CLI with this framework.
https://github.com/tfmigrator/cli