← All insightsAutomation

Automating OpenTofu from scratch

CodeWizard Academy · 7 December 2025 · 3 min read · Intermediate

Anything you do to OpenTofu twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.

1. Install it reproducibly

bash
brew install opentofu
tofu version
tofu init

2. Describe the desired state

Identical HCL to Terraform - just run with tofu.

hcl
terraform {
  required_providers { aws = { source = "hashicorp/aws" } }
  encryption {          # OpenTofu native state encryption
    key_provider "pbkdf2" "k" { passphrase = var.state_pass }
    method "aes_gcm" "m" { keys = key_provider.pbkdf2.k }
    state { method = method.aes_gcm.m }
  }
}

3. Run it from CI

Swap the binary; the workflow is the same as Terraform.

yaml
- uses: opentofu/setup-opentofu@v1
- run: tofu init -input=false && tofu plan -input=false

Want senior help putting OpenTofu to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult