> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenTofu Plugin

> The official OpenTofu engine plugin — generates main.tf HCL and wraps the tofu CLI.

The `ubx-plugin-opentofu` plugin is functionally identical to the Terraform plugin but delegates to the `tofu` CLI instead of `terraform`. It generates the same `main.tf` HCL format.

## Install

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx plugin install opentofu
```

## Configure

In `workspace.xcl`:

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
workspace {
  engine = "opentofu"
}
```

## Prerequisites

The `tofu` binary must be on `$PATH`. Install from [opentofu.org](https://opentofu.org/docs/intro/install/).

## Generated output

Same as the Terraform plugin — generates `.ubx/main.tf`. See [Terraform plugin](/v1/plugins/terraform) for the full mapping reference.

## Differences from Terraform plugin

* Calls `tofu` instead of `terraform` for all operations
* Compatible with OpenTofu 1.6+
* Supports OpenTofu-specific features where applicable (native state encryption, etc.)

## Plugin RPCs

| RPC       | Description                                 |
| --------- | ------------------------------------------- |
| `Compile` | Generates `main.tf`, returns `artifact_uri` |
| `Plan`    | Runs `tofu plan`, returns summary           |
| `Apply`   | Runs `tofu apply`, streams events           |
| `Destroy` | Runs `tofu destroy`, streams events         |

## Migrating from Terraform to OpenTofu

Change the engine in `workspace.xcl`:

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
workspace {
  engine = "opentofu"   // was: "terraform"
}
```

Install the OpenTofu binary and the plugin:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx plugin install opentofu
```

The existing state and `.xcl` files are fully compatible — no changes required.
