Interview Prep/Terraform/Refactoring, Migration and Drift

How do you migrate from Terraform to OpenTofu in production?

AdvancedProductionRefactoring, Migration and Drift
Answer

Pin and match the current Terraform version's feature set, back up all state, install tofu in a branch pipeline, run tofu init and tofu plan for every stack and require empty plans. Roll out stack by stack, since once OpenTofu writes state the Terraform CLI may refuse to read newer formats. Keep a documented rollback (state backup plus Terraform binary) and check any providers or modules sourced only from HCP.

All Terraform questions Roadmap: Terraform in production

More on Refactoring, Migration and Drift