移行

Terraform から OpenTofu への移行

ライセンスと利用条件

Terraform
Other, ソースアベイラブル
OpenTofu
MPL-2.0, オープンソース
置き換えの度合い
ドロップイン Fork of Terraform 1.5, reads the same configuration and state.

このページは英語で書かれています。

Compatibility

OpenTofu aims to stay compatible with Terraform configurations, and the project says most code runs without changes. Your .tf files, modules and state are used as they are: tofu init downloads providers from the OpenTofu registry and initialises the same backend, then tofu plan reads the existing state.

“Most” is the operative word. The only proof that your configuration is one of them is a plan that shows no changes.

Before you switch

  1. Back up the state. For local state, copy terraform.tfstate and its backup file. For remote state, use your backend’s own mechanism, such as bucket versioning or a snapshot.
  2. Commit the configuration, ideally on a branch made for the migration.
  3. Install OpenTofu and check it with tofu --version.
  4. In the project directory, run tofu init, then tofu plan. You want “No changes”, or exactly the plan Terraform would print.
  5. If the plan shows anything you did not expect, do not apply it. Find out why first.
  6. Run tofu apply once even with no changes, so OpenTofu can update the state format if it needs to.
  7. Make a small, harmless change, such as a tag, and plan and apply it to confirm OpenTofu manages the infrastructure.

Pitfalls

公式ガイド

OpenTofuの移行ガイド ↗

2026-09-24にレビュー済み。

出典

Terraformのその他の代替 →