Skip to content
Back to skills

Opentofu Knowledge Patch

ASecurity

OpenTofu

  • 25 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentgoshellsqlexpresskubernetesawsazureterraformtestingdatabase

Works with

  • cli
  • mcp

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill opentofu-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Opentofu Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Opentofu Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-opentofu-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-opentofu-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: opentofu-knowledge-patch
description: OpenTofu
version: "1.13.11"
license: MIT
metadata:
  author: Nevaberry
---


# OpenTofu compatibility guidance

Load this skill when updating OpenTofu configurations, automation, state
encryption, provider installation, or tests. Use the topic references for
complete configuration examples and branch-specific patch requirements.

| Reference | Topics |
| --- | --- |
| [Backends, distribution, and platforms](references/backends-distribution-and-platforms.md) | Backend migrations and authentication, state persistence, registries, caches, checksums, operating systems, provisioners, security fixes |
| [CLI, automation, and output](references/cli-automation-and-output.md) | Planning selectors, generated configuration, JSON events, diagnostics, inspection, console, environment, tracing, completion |
| [Language, modules, and lifecycle](references/language-modules-and-lifecycle.md) | Static evaluation, provider iteration and functions, validation, sensitivity, imports, lifecycle, ephemeral values, experimental language features |
| [State and plan encryption](references/state-and-plan-encryption.md) | Enforcement, overrides, key providers, rotation, plaintext rollback, metadata aliases, remote state, external protocols |
| [Testing and Go tooling](references/testing-and-go-tooling.md) | Test inputs and runs, mocks, overrides, cleanup, Go libraries, editors, registry documentation |

## Migrations and breaking changes

### Backend configuration

- Remove `use_legacy_workflow` before upgrading to 1.8.0. The S3 backend's
  standard SDK credential lookup order becomes mandatory.
- When adopting independent PostgreSQL states with `table_name` and
  `index_name`, upgrade every OpenTofu client using that database together:
  older clients use incompatible locks and can make conflicting writes.
- For the AzureRM backend migration, `endpoint` and `ARM_ENDPOINT` are ignored.
  Replace `msi_endpoint` or `ARM_MSI_ENDPOINT` with `MSI_ENDPOINT`, set at most
  one of `environment` and `metadata_host`, and run `tofu init -reconfigure`
  in an initialized directory to reload settings at the existing state location.
- S3 module downloads use the SDK credential search order, including IAM roles
  for service accounts. Check the selected identity after upgrading when more
  than one credential source is configured.
- Module sources using `s3::http://` use plaintext HTTP for custom endpoints.
  Use `s3::https://` to keep HTTPS; official AWS hostnames continue to use HTTPS.

### Automation and provisioner compatibility

- Remove `OPENTOFU_USER_AGENT` from automation that used it to override the
  default HTTP User-Agent.
- `TF_CLI_ARGS` and its subcommand variants pass an empty quoted token such as
  `''` as a zero-length argument. Remove it when the intent is to omit an argument.
- Starting in 1.12.13 and 1.13.11, SSH provisioners verify the bastion with
  `bastion_host_key`. If the connection relied on `host_key` for this check,
  set `bastion_host_key` to the same value.
- TLS handshakes reject SHA-1 signatures. The `remote-exec` and `file`
  provisioners reject SSH certificates signed with a certificate key;
  use a plain signing key to issue those certificates.
- The `winrm` connection type emits warnings in 1.12, with errors expected
  in 1.13. Windows hosts can migrate to OpenSSH; PowerShell over SSH works
  again with `remote-exec`.

### Output and test compatibility

`base64gzip` can produce a different encoded string for the same input in
1.13. Compare decompressed content with `base64gunzip` when tests only need
to check the payload.

`tofu test` fails on invalid fields in mocks and overrides. Generated mock
values follow provider schemas more closely; correct defaults and overrides
that older releases accepted despite mismatched schemas.

Module authors can deprecate individual inputs and outputs. Callers receive
warnings when supplying deprecated inputs or reading deprecated outputs.
References to provider-schema-deprecated resource attributes or blocks also
emit warnings; `-deprecation` controls these diagnostics.

## State and plan encryption

`TF_ENCRYPTION` takes the contents of the `encryption` block directly and
overrides file settings on merge. Keep `enforced = true` in the file for
each of `state` and `plan` that must be encrypted, so omitting the environment
variable fails closed:

```hcl
terraform {
  encryption {
    state { enforced = true }
    plan  { enforced = true }
  }
}
```

Encryption variables and locals must resolve during `tofu init`, before
OpenTofu has state or provider-defined functions. `tofu init -backend=false`
skips reading encryption keys. Operations load only the methods and key
providers they need.

To rotate a PBKDF2 passphrase or switch key management systems, retain the old provider and method blocks and
reference the old method from `fallback` in `state` or `plan`. Existing files
remain readable while writes use the primary method. For plaintext rollback,
disable `enforced`, make `unencrypted` primary, and keep the original method
as fallback. Run `tofu apply` to rewrite state, then remove the `state` block.
Use the same primary/fallback arrangement when migrating plan encryption.

Metadata depends on configured names. Use rollover for existing names, or
set a unique `encrypted_metadata_alias` before writing encrypted files.
Projects sharing encrypted state with different provider labels use the same alias.

Use `remote_state_data_sources` to select decryption methods for
`terraform_remote_state`, independently of the project's own state method.
External key providers and external encryption methods are experimental;
their protocols and examples are in the encryption reference.

## Static inputs and provider instances

Module sources, registry module versions, and backend settings can use inputs
and locals. Values must be available during `tofu init`, before resources,
data sources, or provider-defined functions can be evaluated. OpenTofu can
prompt for missing inputs needed during early evaluation. Backend configuration
and module source expressions that evaluate to sensitive values are rejected.

Set `const = true` on an input variable to require a value compatible with
static evaluation. The `language` block lets modules declare OpenTofu-specific
version constraints; adopt it once a module can require OpenTofu 1.12 or later.

Set `for_each` on an aliased provider configuration and select instances with
expressions such as `provider = aws.by_region[each.key]`. Computed indices in
resource provider selections and module provider mappings convert to strings.
Call provider functions with `provider::<provider_name>::<function_name>(args)`,
using the local provider name.

## Imports, lifecycle, and ephemeral values

Use `for_each` in an `import` block to import multiple instances. Index keys
in `to` can use expressions. For provider-defined identities, supply an object
matching the resource type's identity schema and choose exactly one of
`identity` and `id`. `tofu destroy` skips import blocks.

Set `enabled` inside `lifecycle` to choose between zero and one instances
while retaining the unindexed address when enabled. Guard references with the
same condition. Use a non-ephemeral condition; 1.11.1 fixes its serialization
in saved plans. Starting in 1.11.4, module calls using `enabled` are rejected
when the child module defines its own provider configurations.

A managed resource's `lifecycle.prevent_destroy` can reference values in the same module, including
inputs. `replace_triggered_by` triggers replacement when the referenced
resource is itself replaced; validation and planning check referenced attributes.

On a managed resource, `lifecycle { destroy = false }` removes it from state
and keeps the remote object when a plan would destroy it. Use 1.12.4 or later
to save a plan that replaces a resource with this setting. For references in
`lifecycle.destroy` expressions, use 1.12.8 or later on the 1.12 branch or
1.13.2 or later on the 1.13 branch. `tofu destroy -suppress-forget-errors`
exits successfully if forgotten resources are the only errors.

Mark inputs and child module outputs with `ephemeral = true` to keep their
values out of state snapshots and saved plans. Supporting providers can supply
ephemeral resources for temporary credentials or connections used by providers
or provisioners, and accept transient secrets in managed-resource write-only
arguments. Use a non-ephemeral value for `count`.

Supply encryption inputs when applying a saved plan, for example
`tofu apply -var-file=encryption.tfvars run.tfplan`. Non-ephemeral values
supplied at apply must match their values during planning.

## CLI and automation shortcuts

- `tofu plan -exclude=kubernetes_manifest.crds` omits the selected object
  and everything that depends on it. Use `-target-file=targets.txt` or
  `-exclude-file=exclusions.txt` with `tofu plan` for selections stored in files.
- `tofu plan -concise` suppresses per-resource refresh messages;
  `tofu apply -concise` suppresses progress messages.
- `-json-into=run.jsonl` writes machine-readable logs while human-readable
  output continues. Streaming commands also accept a named pipe or `/dev/fd/N`.
- `tofu show -state` inspects state; `tofu show -plan=run.tfplan` inspects a
  saved plan. `tofu show -json -config` emits configuration JSON without a plan.
- `tofu console -lock-timeout=30s` waits for the state lock;
  use `tofu console -lock=false` on 1.12.3 or later to skip locking.
- `tofu plan -show-sensitive` and `tofu apply -show-sensitive` display values
  that would otherwise be masked.

## Provider distribution and verification

Multiple processes can share `TF_PLUGIN_CACHE_DIR` when its filesystem
supports file locking. Keep valid `.terraform.lock.hcl` files in participating
projects; use 1.10.5 or later for the cache lock contention fix. Version 1.12.2
fixes spurious deadlock reports during concurrent cache use on Unix.

When a registry supplies cross-platform checksums, `tofu init` records them
for all supported platforms, including `h1:` hashes. This can replace a separate
`tofu providers lock` step. When provider installation is routed exclusively
through a mirror or alternative source, use `tofu providers lock` to fetch
official checksums from origin registries.

## Tests and development tools

`mock_provider` substitutes a provider in `.tftest.hcl`; nested `mock_resource`
and `mock_data` blocks supply defaults by type. Target specific addresses with
`override_resource`, `override_data`, or `override_module`. Resource and data
overrides take `values`; module overrides take `outputs`.

Runs can consume outputs from earlier runs in their `variables` blocks, and
test provider configurations can use earlier outputs. Cleanup occurs in reverse
run order. Failed cleanup writes a state file for finding and removing remaining
resources. Read module outputs before a run destroys that module.

Use `tofu-ls` with LSP-compatible editors for completion, diagnostics, and
documentation lookup. Registry provider and module documentation is available
through the MCP endpoint `https://mcp.opentofu.org/mcp` or a local Registry MCP server.

Plan-time hint functions let module authors supply facts the planner cannot
infer, reducing unknowns. Built-in linting has early experimental support.
Symbol libraries are an experimental design for sharing values, functions,
and type aliases using the same source types as modules. Use 1.13.2 or later
for saved plans with symbol libraries; 1.13.10 enables planning when modules
use them and fixes a crash when a library is uninitialized.

Files in this skill

  • SKILL.md9.4 KB
  • coverage.json1 KB
  • references/backends-distribution-and-platforms.md7.8 KB
  • references/cli-automation-and-output.md4.5 KB
  • references/language-modules-and-lifecycle.md7 KB
  • references/state-and-plan-encryption.md5.2 KB
  • references/testing-and-go-tooling.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.