website/docs/intro/migration/migration-guide.mdx
This guide walks you through migrating from Terraform to OpenTofu. It is designed to be safe and reversible, allowing you to test OpenTofu without disrupting your existing infrastructure.
:::note Do you have multiple Terraform configurations to migrate?
Some systems are built from multiple Terraform configurations that propagate data using the terraform_remote_state data source, which typically requires some additional care during migration.
For more information, refer to Migrating interdependent configurations. :::
terraform and tofu commands during the migrationBefore starting the migration, create backups of:
Your Terraform state files
terraform.tfstate and terraform.tfstate_backup filesYour Terraform configuration files
Follow the installation guide to install OpenTofu on your system. Verify the installation:
tofu --version
In your Terraform project directory, initialize OpenTofu:
tofu init
This command will:
Run a plan to ensure OpenTofu can read your state and configuration:
tofu plan
Expected result: You should see "No changes" or the same plan output you would see with Terraform.
If you see unexpected changes:
Once you've verified the plan shows no unexpected changes, run:
tofu apply
Even if there are no infrastructure changes, this ensures OpenTofu updates the state file format if needed.
Make a small, non-critical change to your configuration (e.g., add a tag to a resource) and run:
tofu plan
tofu apply
This verifies that OpenTofu can successfully manage your infrastructure going forward.
If you encounter issues during migration, you can safely roll back:
terraform init
terraform plan
If you encounter issues during migration: