ops0ops0

Migrate Between Terraform and OpenTofu

Switch an existing IaC project between Terraform and OpenTofu without recreating it. ops0 handles the CLI swap and updates internal tags so future deployments use the target engine.

When to Migrate

ScenarioDirection
Move to open-source licensingTerraform → OpenTofu
Need a HashiCorp-specific provider featureOpenTofu → Terraform
Organization standardizing on one engineEither direction
Compatibility

Terraform and OpenTofu are fully compatible at the configuration level. Your .tf files, state files, and providers work with both engines without modification.


What Changes

AspectBeforeAfter
CLI used for plan/applyterraformtofu (or vice versa)
ManagedIaC tagsUpdated to reflect new engineAutomatically rewritten
State fileNo change — same formatCompatible across both
Provider pluginsRe-downloaded on first runSame registry sources
Configuration filesNo changeNo change

What does not change:

  • Your .tf files remain identical
  • State backend configuration stays the same
  • Policy mappings and compliance status are preserved
  • GitHub sync continues working
  • Deployment history is retained

How to Migrate

Open Project Settings

Navigate to IaC → Projects and find the project you want to migrate.

Click Migrate

In the project actions menu, select Migrate to OpenTofu or Migrate to Terraform depending on the current engine.

Review the Impact

A confirmation dialog explains what will change:

  • Future deployments will use the target CLI
  • ops0 will review code and update ManagedIaC tags
  • Existing state and configuration are preserved

Confirm Migration

Click Confirm to proceed. The migration completes in seconds.

Verify

Run a Plan to confirm the project works correctly with the new engine. You should see no unexpected changes.


Migration Considerations

Provider Compatibility

Most providers work identically across Terraform and OpenTofu. Check for edge cases:

ProviderNotes
AWSFully compatible
GCPFully compatible
AzureFully compatible
Oracle CloudFully compatible
HashiCorp VaultMay require version pinning on OpenTofu

State File Compatibility

Terraform and OpenTofu use the same state file format. Migration does not modify your state file. You can migrate back and forth without state issues.

Lock File

The .terraform.lock.hcl file is compatible between both engines. On first plan after migration, the target CLI may update provider checksums in the lock file — this is normal.


Rollback

If you need to switch back, repeat the same process in reverse. There is no one-way commitment — you can migrate between Terraform and OpenTofu as needed.