Skip to content
opentofu-guide logo

OpenTofu Expertise and Migration Guide

opentofu-guide

OpenTofu (Terraform open-source fork) guide and migration. PROACTIVELY activate for: (1) OpenTofu installation and tofu CLI usage, (2) migrating from Terraform CLI to OpenTofu, (3) provider compatibility between Terraform and OpenTofu, (4) state file compatibility, (5) OpenTofu-specific features ...

SKILL.md

Full skill instructions

<!-- Progressive Disclosure References: - references/​opentofu-1.10-features.md - OCI registry, native S3 locking, deprecation warnings - references/​opentofu-1.11-features.md - Ephemeral resources, enabled meta-argument - references/​state-encryption.md - Complete state encryption guide with KMS integration -->

🚨 CRITICAL GUIDELINES

Windows File Path Requirements

MANDATORY: Always Use Backslashes on Windows for File Paths

When using Edit or Write tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).

Examples:

  • ❌ WRONG: D:/​repos/​project/​file.tsx
  • ✅ CORRECT: D:\repos\project\file.tsx

This applies to:

  • Edit tool file_path parameter
  • Write tool file_path parameter
  • All file operations on Windows systems

Documentation Guidelines

NEVER create new documentation files unless explicitly requested by the user.

  • Priority: Update existing README.md files rather than creating new documentation
  • Repository cleanliness: Keep repository root clean - only README.md unless user requests otherwise
  • Style: Documentation should be concise, direct, and professional - avoid AI-generated tone
  • User preference: Only create additional .md files when user specifically asks for documentation

OpenTofu Expertise and Migration Guide

Overview

OpenTofu is the open-source fork of Terraform, created in 2023 after HashiCorp changed Terraform's license from MPL 2.0 to BSL (Business Source License). OpenTofu is stewarded by the Linux Foundation and maintains full compatibility with Terraform 1.5.x while adding community-driven features.

Key Differences (2025)

Licensing

Terraform (HashiCorp):

  • BSL (Business Source License) since August 2023
  • Restrictions on commercial use for competing products
  • IBM acquired HashiCorp in 2024

OpenTofu:

  • MPL 2.0 (Mozilla Public License)
  • True open-source
  • Linux Foundation governance
  • Community-driven development

Feature Innovations (2025)

OpenTofu 1.7 Features:

  • State Encryption: Client-side encryption (community requested for 5+ years)
  • Loop-able Import Blocks: for_each in import blocks
  • Dynamic Provider Functions: Provider-defined functions support
  • Early Variable Evaluation: Variables in terraform block

OpenTofu 1.8 Features (Latest):

  • OpenTofu-Specific Overrides: Balance compatibility with innovation
  • Early Variable Evaluation Expanded: Use variables/​locals in module sources
  • Enhanced Provider Support: Improved provider SDK

Terraform Advantages:

  • HCP Terraform: Cloud platform with Stacks, HYOK, Private VCS Access
  • Enterprise Support: Direct HashiCorp/​IBM support
  • Larger Ecosystem: More established marketplace
  • Sentinel Policies: Policy-as-code framework (350+ NIST policies)

Compatibility

100% Compatible:

  • HCL syntax (same language)
  • Provider ecosystem (same registry access)
  • State file format (Terraform 1.5.x)
  • Module structure
  • CLI commands

Migration Path:

  • Drop-in replacement for Terraform 1.5.x
  • No code changes required
  • State files portable (with encryption consideration)

When to Use OpenTofu vs Terraform

Choose OpenTofu When:

  1. Open-Source Requirements:

    • Organization policy requires open-source tools
    • Want vendor neutrality
    • Concerned about future license changes
  2. State Encryption Needed:

    • Compliance requires client-side encryption
    • Want encryption without HCP Terraform
    • Multi-cloud encryption requirements
  3. Cost Optimization:

    • Want free state encryption
    • No need for HCP Terraform features
    • Budget constraints on tooling
  4. Community-Driven:

    • Want to influence roadmap
    • Prefer Linux Foundation governance
    • Value community contributions

Choose Terraform When:

  1. Enterprise Features Required:

    • Need HCP Terraform Stacks
    • Require HYOK (Hold Your Own Key)
    • Want Private VCS Access
    • Need Sentinel policy enforcement
  2. Enterprise Support:

    • Want direct HashiCorp/​IBM support
    • Need SLA guarantees
    • Require compliance certifications
  3. Advanced Features:

    • Ephemeral values (1.10+)
    • Terraform Query (1.14+)
    • Actions blocks (1.14+)
    • Latest provider features first
  4. Established Ecosystem:

    • Existing HCP Terraform investment
    • Tight integration needs
    • Mature tooling requirements

Migration from Terraform to OpenTofu

Step 1: Assess Compatibility

# Check Terraform version
terraform version
# Must be 1.5.x or compatible

# Check provider versions
terraform providers
# All providers compatible (same registry)

Step 2: Install OpenTofu

Windows:

# Chocolatey
choco install opentofu

# Scoop
scoop install opentofu

# Manual
# Download from https://github.com/​opentofu/​opentofu/​releases

macOS:

# Homebrew
brew install opentofu

# Manual
curl -L https://github.com/​opentofu/​opentofu/​releases/​download/​v1.8.0/​tofu_1.8.0_darwin_amd64.tar.gz | tar xz
sudo mv tofu /​usr/​local/​bin/

Linux:

# Snap
snap install opentofu --classic

# Debian/​Ubuntu
curl -fsSL https://get.opentofu.org/​install-opentofu.sh | sh

# Manual
wget https://github.com/​opentofu/​opentofu/​releases/​download/​v1.8.0/​tofu_1.8.0_linux_amd64.tar.gz
tar -xzf tofu_1.8.0_linux_amd64.tar.gz
sudo mv tofu /​usr/​local/​bin/

Step 3: Test Compatibility

# Navigate to Terraform directory
cd /​path/​to/​terraform/​project

# Initialize with OpenTofu (non-destructive)
tofu init

# Validate configuration
tofu validate

# Generate plan (compare with Terraform plan)
tofu plan

Step 4: Migrate State (Optional)

If NOT using state encryption:

# State is compatible - no migration needed
# Just switch from 'terraform' to 'tofu' commands

# Verify state
tofu show

If ENABLING state encryption:

# Configure encryption in .tofu file
cat > .tofu <<EOF
encryption {
  state {
    method = "aes_gcm"
    keys {
      name = "my_key"
      passphrase = env.TOFU_ENCRYPTION_KEY
    }
  }

  plan {
    method = "aes_gcm"
    keys {
      name = "my_key"
      passphrase = env.TOFU_ENCRYPTION_KEY
    }
  }
}
EOF

# Set encryption key
export TOFU_ENCRYPTION_KEY="your-secure-passphrase"

# Migrate state (automatically encrypts)
tofu init -migrate-state

Step 5: Update CI/​CD

GitHub Actions:

# Before (Terraform)
- uses: hashicorp/​setup-terraform@v3
  with:
    terraform_version: 1.5.0

# After (OpenTofu)
- uses: opentofu/​setup-opentofu@v1
  with:
    tofu_version: 1.8.0

# Or manual install
- name: Install OpenTofu
  run: |
    curl -fsSL https://get.opentofu.org/​install-opentofu.sh | sh
    tofu version

Azure DevOps:

# Before
- task: TerraformInstaller@0
  inputs:
    terraformVersion: '1.5.0'

# After
- task: Bash@3
  displayName: 'Install OpenTofu'
  inputs:
    targetType: 'inline'
    script: |
      curl -fsSL https://get.opentofu.org/​install-opentofu.sh | sh
      tofu version

GitLab CI:

# Before
image: hashicorp/​terraform:1.5.0

# After
image: ghcr.io/​opentofu/​opentofu:1.8.0

State Encryption (OpenTofu Exclusive)

Configuration

Basic Encryption:

# .tofu or terraform.tf
encryption {
  state {
    method = "aes_gcm"
    keys {
      name = "primary_key"
      passphrase = env.TOFU_STATE_ENCRYPTION_KEY
    }
  }
}

Key Rotation:

encryption {
  state {
    method = "aes_gcm"
    keys {
      # New key
      name = "key_v2"
      passphrase = env.TOFU_KEY_V2

      # Old key (for decryption)
      fallback {
        name = "key_v1"
        passphrase = env.TOFU_KEY_V1
      }
    }
  }
}

Cloud KMS Integration:

# AWS KMS
encryption {
  state {
    method = "aws_kms"
    keys {
      name = "aws_key"
      kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/​12345678-1234-1234-1234-123456789012"
    }
  }
}

# Azure Key Vault
encryption {
  state {
    method = "azurerm_key_vault"
    keys {
      name = "azure_key"
      key_vault_key_id = "https://myvault.vault.azure.net/​keys/​mykey/​version"
    }
  }
}

# GCP KMS
encryption {
  state {
    method = "gcp_kms"
    keys {
      name = "gcp_key"
      kms_crypto_key = "projects/​PROJECT_ID/​locations/​LOCATION/​keyRings/​RING/​cryptoKeys/​KEY"
    }
  }
}

Best Practices

  1. Store Keys Securely:

    # Never commit keys
    echo "TOFU_ENCRYPTION_KEY=xxx" >> .env
    echo ".env" >> .gitignore
    
    # Use CI/​CD secrets
    # GitHub: Repository Settings → Secrets
    # Azure DevOps: Pipeline → Variables → Secret
    
  2. Rotate Keys Regularly:

    # Generate new key
    NEW_KEY=$(openssl rand -base64 32)
    
    # Add to fallback, update configs
    # Migrate state
    tofu init -migrate-state
    
  3. Backup Unencrypted State:

    # Before enabling encryption
    terraform state pull > backup-unencrypted.tfstate
    
    # Enable encryption
    tofu init -migrate-state
    
    # Verify
    tofu state pull  # Should be encrypted in backend
    

Loop-able Import Blocks (OpenTofu 1.7+)

Terraform 1.5+ (Single Imports):

import {
  to = azurerm_resource_group.example
  id = "/​subscriptions/​.../​resourceGroups/​my-rg"
}

OpenTofu 1.7+ (Loop Imports):

# Import multiple resource groups
locals {
  resource_groups = {
    "rg1" = "/​subscriptions/​.../​resourceGroups/​rg1"
    "rg2" = "/​subscriptions/​.../​resourceGroups/​rg2"
    "rg3" = "/​subscriptions/​.../​resourceGroups/​rg3"
  }
}

import {
  for_each = local.resource_groups
  to       = azurerm_resource_group.imported[each.key]
  id       = each.value
}

resource "azurerm_resource_group" "imported" {
  for_each = local.resource_groups
  name     = each.key
  location = "eastus"
}

Early Variable Evaluation (OpenTofu 1.7+)

Terraform 1.5.x:

# Variables NOT allowed in terraform block
terraform {
  required_version = ">= 1.5.0"  # Static only

  backend "azurerm" {
    resource_group_name  = "terraform-state"  # Static only
    storage_account_name = "tfstate"
  }
}

OpenTofu 1.7+:

# Variables allowed in terraform block
variable "environment" {
  type = string
}

terraform {
  required_version = ">= 1.7.0"

  backend "azurerm" {
    resource_group_name  = "terraform-state-${var.environment}"
    storage_account_name = "tfstate${var.environment}"
    key                  = "${var.environment}.tfstate"
  }
}

OpenTofu 1.8+ (Module Sources):

variable "module_version" {
  type    = string
  default = "v1.0.0"
}

module "networking" {
  source  = "git::https://github.com/​org/​module.git?ref=${var.module_version}"
  # Dynamic module version!
}

Practical Migration Examples

Example 1: Small Project Migration

# 1. Backup existing state
terraform state pull > backup.tfstate

# 2. Install OpenTofu
brew install opentofu

# 3. Test compatibility
tofu init
tofu plan

# 4. Switch to OpenTofu
alias terraform=tofu  # Optional: maintain muscle memory

# 5. Verify everything works
tofu apply

Example 2: Enterprise Migration with Encryption

# 1. Generate encryption key
ENCRYPTION_KEY=$(openssl rand -base64 32)
echo "TOFU_ENCRYPTION_KEY=$ENCRYPTION_KEY" >> .env.production

# 2. Create encryption config
cat > .tofu <<EOF
encryption {
  state {
    method = "aes_gcm"
    keys {
      name = "prod_key"
      passphrase = env.TOFU_ENCRYPTION_KEY
    }
  }

  plan {
    method = "aes_gcm"
    keys {
      name = "prod_key"
      passphrase = env.TOFU_ENCRYPTION_KEY
    }
  }
}
EOF

# 3. Migrate with encryption
source .env.production
tofu init -migrate-state

# 4. Verify encryption
tofu state pull  # State is now encrypted in backend

Example 3: CI/​CD Migration

# .github/​workflows/​terraform.yml
name: Infrastructure

on: [push, pull_request]

jobs:
  opentofu:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/​checkout@v4

      - name: Setup OpenTofu
        uses: opentofu/​setup-opentofu@v1
        with:
          tofu_version: 1.8.0

      - name: Init
        run: tofu init
        env:
          TOFU_ENCRYPTION_KEY: ${{ secrets.TOFU_ENCRYPTION_KEY }}

      - name: Plan
        run: tofu plan
        env:
          ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
          ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
          ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
          ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
          TOFU_ENCRYPTION_KEY: ${{ secrets.TOFU_ENCRYPTION_KEY }}

      - name: Apply
        if: github.ref == 'refs/​heads/​main'
        run: tofu apply -auto-approve
        env:
          ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
          ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
          ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
          ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
          TOFU_ENCRYPTION_KEY: ${{ secrets.TOFU_ENCRYPTION_KEY }}

Command Compatibility

All Terraform commands work identically in OpenTofu (just replace terraform with tofu):

# Terraform          # OpenTofu
terraform init      → tofu init
terraform plan      → tofu plan
terraform apply     → tofu apply
terraform destroy   → tofu destroy
terraform state     → tofu state
terraform import    → tofu import
terraform validate  → tofu validate
terraform fmt       → tofu fmt
terraform output    → tofu output

Community and Support

OpenTofu Community:

Terraform Community:

  • Forum: HashiCorp Discuss
  • GitHub: hashicorp/​terraform
  • Registry: registry.terraform.io
  • Support: HashiCorp Support Portal

Decision Matrix

FactorTerraformOpenTofu
LicenseBSL (Proprietary)MPL 2.0 (Open Source)
State EncryptionVia HCP Terraform (paid)Built-in (free)
Enterprise FeaturesHCP Terraform (Stacks, HYOK)Community alternatives
GovernanceHashiCorp/​IBMLinux Foundation
SupportCommercial support availableCommunity-driven
InnovationHCP-focusedCommunity-focused
CostFree CLI, paid cloudCompletely free
CompatibilityForward-compatibleTerraform 1.5.x compatible

Recommendations

Start with OpenTofu if:

  • Building new infrastructure
  • No need for HCP Terraform features
  • Want state encryption without cloud costs
  • Prefer open-source tools
  • Budget-conscious

Stay with Terraform if:

  • Using HCP Terraform Stacks
  • Need Sentinel policies
  • Require enterprise support
  • Want latest features first (1.10+)
  • Established HCP investment

Easy to Switch:

  • Both are viable long-term
  • Migration takes < 1 hour for most projects
  • State files portable
  • Can evaluate both without commitment

This skill provides comprehensive OpenTofu knowledge for the terraform-expert agent.

More skills from JosiahSiegel

docker-git-bash-guide logo
JosiahSiegel/claude-plugin-marketplace

docker-git-bash-guide

Docker on Windows with Git Bash / MINGW path conversion. PROACTIVELY activate for: (1) Docker commands failing on Windows Git Bash with path errors, (2) volume mount path conversion (-v $(pwd):/app), (3) MSYS_NO_PATHCONV and MSYS2_ARG_CONV_EXCL workarounds, (4) double-slash escapes (//c/foo) for ...

58 0
View
vitest-3-features logo
JosiahSiegel/claude-plugin-marketplace

vitest-3-features

Vitest 3 features and migration from Vitest 2 (2025). PROACTIVELY activate for: (1) Vitest 3 stable features, (2) workspace mode for monorepos, (3) test annotations and reporter API, (4) projects configuration, (5) browser mode in Vitest 3, (6) inline snapshots and toMatchInlineSnapshot, (7) type...

58 0
View
windows-git-bash-paths logo
JosiahSiegel/claude-plugin-marketplace

windows-git-bash-paths

Windows and Git Bash path handling for SSDT, SqlPackage, and DACPAC files. PROACTIVELY activate for: (1) SqlPackage failing on Git Bash with path errors, (2) DACPAC file path conversion (MSYS, MINGW), (3) shell detection (PowerShell vs Git Bash) for SSDT scripts, (4) MSYS_NO_PATHCONV usage, (5) W...

58 0
View
debugging-troubleshooting-2025 logo
JosiahSiegel/claude-plugin-marketplace

debugging-troubleshooting-2025

Comprehensive bash script debugging and troubleshooting techniques for 2025. PROACTIVELY activate for: (1) debugging a misbehaving bash script, (2) using set -x, set -e, set -u, set -o pipefail (strict mode), (3) customizing PS4 for richer trace output, (4) trap DEBUG, ERR, and EXIT for diagnosti...

58 0
View
tailwindcss-accessibility logo
JosiahSiegel/claude-plugin-marketplace

tailwindcss-accessibility

Tailwind CSS accessibility patterns including WCAG 2.2 compliance, touch targets, focus management, and ARIA. PROACTIVELY activate for: (1) building accessible UI with Tailwind, (2) WCAG 2.2 compliance (Level A, AA, AAA), (3) focus rings and focus-visible styling, (4) minimum touch-target sizes (...

58 0
View
git-2-49-features logo
JosiahSiegel/claude-plugin-marketplace

git-2-49-features

Git 2.49 specific features and performance improvements. PROACTIVELY activate for: (1) git-backfill command (new in 2.49) for partial clones, (2) path-walk API improvements, (3) zlib-ng integration for faster compression, (4) reftables backend stabilization, (5) revision-walk performance, (6) bun...

58 0
View
sql-server-2025 logo
JosiahSiegel/claude-plugin-marketplace

sql-server-2025

SQL Server 2025 and SqlPackage 170.2.70 (October 2025) — vector databases, AI integration, and modern features. PROACTIVELY activate for: (1) SQL Server 2025 features, (2) vector type and vector indexes for AI, (3) Vector functions (VECTOR_DISTANCE, etc.), (4) AI integration (Azure OpenAI, embedd...

58 0
View
docker-security-guide logo
JosiahSiegel/claude-plugin-marketplace

docker-security-guide

Comprehensive Docker security guidelines and threat mitigation. PROACTIVELY activate for: (1) container security review, (2) running as non-root user, (3) read-only root filesystems and tmpfs mounts, (4) capability dropping (--cap-drop ALL), (5) seccomp and AppArmor profiles, (6) image vulnerabil...

58 0
View
powershell-security logo
JosiahSiegel/claude-plugin-marketplace

powershell-security

Modern PowerShell security practices for 2025 — SecretManagement, JEA, WDAC, credential protection. PROACTIVELY activate for: (1) Microsoft.PowerShell.SecretManagement and SecretStore for credential storage, (2) Just Enough Administration (JEA) endpoints, (3) Windows Defender Application Control ...

58 0
View
nextjs-middleware logo
JosiahSiegel/claude-plugin-marketplace

nextjs-middleware

Complete Next.js Middleware system (Next.js 15.5/16). PROACTIVELY activate for: (1) Creating middleware.ts (Edge) or proxy.ts (Node.js), (2) Matcher configuration, (3) Authentication protection, (4) Role-based access control, (5) Redirects and rewrites, (6) Internationalization (i18n), (7) Securi...

58 0
View
nextjs-data-fetching logo
JosiahSiegel/claude-plugin-marketplace

nextjs-data-fetching

Complete Next.js data fetching system (Next.js 15.5/16). PROACTIVELY activate for: (1) Server Component data fetching, (2) Parallel and sequential fetching, (3) Streaming with Suspense, (4) Route Handlers (API routes), (5) Client-side fetching with SWR/TanStack Query, (6) generateStaticParams for...

58 0
View
advanced-features-2025 logo
JosiahSiegel/claude-plugin-marketplace

advanced-features-2025

Advanced Claude Code plugin features for hooks, MCP integration, team distribution, and progressive disclosure. PROACTIVELY activate for: (1) progressive disclosure design, (2) hook automation, (3) PreToolUse and PostToolUse hooks, (4) MCP server integration, (5) .mcp.json configuration, (6) team...

58 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View