Skip to content
Back to skills

Opentofu Knowledge Patch

ASecurity

OpenTofu

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

Works with

  • cli

Security analysis

A100/100

Pro scans all 8 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-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-opentofu-knowledge-patch-nevaberry-plugins)

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 Knowledge Patch

Load this skill when configuring or upgrading OpenTofu, maintaining automation,
or diagnosing language, backend, encryption, installation, or test behavior.
Use the topic references for complete guidance and branch-specific fixes.

## Reference index

| Reference | Topics |
| --- | --- |
| [Upgrade, security, and platforms](references/upgrade-security-and-platforms.md) | Provisioner migration, signatures, security fixes, platform minimums, package retirement |
| [State and plan encryption](references/encryption.md) | Environment overrides, rollover, remote state, key providers, experimental external protocols |
| [Language, modules, and lifecycle](references/language-modules-and-lifecycle.md) | Early evaluation, providers, imports, moves, lifecycle, ephemeral values, functions |
| [State, backends, and installation](references/state-backends-and-installation.md) | State persistence, locking, backend settings, module downloads, provider caches and checksums |
| [Testing](references/testing.md) | Test inputs, mocks, overrides, output dependencies, cleanup, ephemeral resources |
| [CLI, automation, and libraries](references/cli-automation-and-libraries.md) | Output controls, inspection, tracing, editors, registry tools, experimental libraries |

## Breaking changes and deprecations

### Backend and credential migrations

Remove `use_legacy_workflow` from S3 backend configurations when upgrading to
1.8: the standard SDK credential lookup order is mandatory. Backend-configured
credentials take precedence over environment variables.

The `azurerm` backend ignores `endpoint` and `ARM_ENDPOINT`. Replace
`msi_endpoint` or `ARM_MSI_ENDPOINT` with the `MSI_ENDPOINT` environment variable,
and set at most one of `environment` and `metadata_host`. Run
`tofu init -reconfigure` in an initialized directory to reload these settings
at the existing state location.

Upgrade every OpenTofu client using a PostgreSQL backend database together:
older clients use incompatible locks and can make conflicting writes.

### Provisioner connections

The `winrm` connection type for `remote-exec` and `file` 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`.

Starting in 1.12.13 and 1.13.11, SSH provisioner connections use
`bastion_host_key` to verify the bastion. If the connection previously relied on
`host_key` for that 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.

### Automation and module downloads

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 if the intent is omission.

Module sources starting with `s3::http://` use plaintext HTTP for custom endpoints.
Use `s3::https://` to keep HTTPS for those endpoints. Official AWS hostnames
continue to use HTTPS.

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

### Validation and deprecation diagnostics

`tofu test` fails on invalid fields in mocks and overrides. Correct fields that
earlier releases reported as warnings before running the suite on 1.9.
Generated mock values follow provider schemas more closely in 1.11; correct
mock defaults and overrides accepted by older releases despite schema mismatches.

Module authors can deprecate individual input variables and output values.
Other modules receive warnings when supplying those inputs or reading those outputs.
References to provider-schema-deprecated resource attributes or blocks emit
warnings; `-deprecation` controls these diagnostics.

## Encryption configuration and migration

### Fail-closed environment overrides

`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.
Encryption variables and locals must resolve during `tofu init`, before state
or provider-defined functions are available.

Use 1.12.3 or later if automation may set `TF_ENCRYPTION` to spaces only.
On earlier 1.12 releases, unset the variable when there is no override.

### Rotate keys or return to plaintext

Keep old key provider and method blocks alongside replacements. Reference the old
method from `fallback` in `state` or `plan` to read existing files while writing
with the primary method. Set a unique `encrypted_metadata_alias` before writing
encrypted files if a key-provider label must later be renamed while retaining its alias.

To remove encryption, retain the original method and key provider, disable
`enforced`, make `unencrypted` primary, and put the original method in `fallback`.
Run `tofu apply` to rewrite state, then remove the `state` block. Use the same
primary and fallback arrangement when migrating plan encryption.

### Remote readers and saved plans

Configure `remote_state_data_sources` inside `terraform.encryption` independently
of the project's own `state` method. `default` covers readers without an override;
reader labels can select root, module, or indexed readers such as `network.vpc[0]`.

Supply encryption variables when applying saved plans, for example
`tofu apply -var-file=encryption.tfvars run.tfplan`. Non-ephemeral values supplied
at apply must match their planning values. `tofu init -backend=false` skips
reading encryption keys.

## Language and resource workflows

### Early evaluation and file selection

Module sources, registry module versions, and backend settings can use inputs and
locals available during `tofu init`, before resources, data sources, or provider
functions can be evaluated. Set `const = true` to require an input value compatible
with static evaluation. Backend configuration and module source expressions that
evaluate to sensitive values are rejected in 1.9.

If both `network.tofu` and `network.tf` exist, OpenTofu loads `network.tofu` and
ignores `network.tf`. Put the full OpenTofu version of that file in `network.tofu`.

### Provider instances and imports

Set `for_each` on an aliased provider configuration and select instances with
`provider = aws.by_region[each.key]`. Provider functions use the provider's local
name: `provider::<provider_name>::<function_name>(args)`.

An `import` block can use `for_each`; index keys in `to` can use expressions,
including variables, locals, conditionals, and resource or data source references.
For provider-defined import identities, supply an object matching the resource
type's identity schema and choose exactly one of `identity` and `id`.
`tofu destroy` skips `import` blocks.

### Conditional objects and destruction

Set `enabled` inside `lifecycle` to choose between zero and one instances while
keeping the unindexed address when enabled. Guard references with the same condition
when the object can be absent, and use a non-ephemeral condition.
Starting in 1.11.4, a module call using `enabled` is rejected if its child module
defines its own provider configurations.

`lifecycle.prevent_destroy` can reference values in the same module, including
inputs. 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.

`replace_triggered_by` triggers replacement when a referenced resource is itself
replaced. Validation and planning check that referenced attributes exist.

### Ephemeral values

Mark input variables and child module outputs with `ephemeral = true` to keep
their values out of state snapshots and saved plans. With provider support, use
`ephemeral` resource blocks for temporary credentials or connections used by
providers or provisioners, and pass transient secrets to write-only arguments.

Use a non-ephemeral value for `count`; supply the instance count separately if
the configuration also takes an ephemeral input. Starting in 1.13.1, ephemeral
outputs are always reevaluated during apply so consumers receive that phase's value.

## Installation, automation, and testing

### Provider installation and state locking

Multiple processes can share `TF_PLUGIN_CACHE_DIR` if its filesystem supports file
locking. Keep valid `.terraform.lock.hcl` files in participating projects and use
1.10.5 or later for the cache lock contention fix.

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

The S3 backend can lock state directly in the bucket as an alternative to DynamoDB.
Use 1.10.2 or later if the lockfile requires `x-amz-server-side-encryption`.

### Plan selection and output

`tofu plan -exclude=kubernetes_manifest.crds` omits the selected object and
everything that depends on it. Use `tofu plan -target-file=targets.txt` or
`tofu plan -exclude-file=exclusions.txt` for resource instance addresses in a file.

Use `-json-into=run.jsonl` for machine-readable logs alongside human-readable output.
Streaming JSON destinations can be named pipes or special files such as `/dev/fd/N`.
`tofu plan -concise` suppresses per-resource refresh messages;
`tofu apply -concise` suppresses progress messages.

Use `tofu show -json -config` for configuration JSON without a plan, or
`tofu show -state` and `tofu show -plan=run.tfplan` for explicit state or plan inspection.

### Test mocks, dependencies, and cleanup

Declare `mock_provider` in `.tftest.hcl`; nested `mock_resource` and `mock_data`
blocks supply defaults by type. `override_resource` and `override_data` take
`values`; `override_module` takes `outputs`.

A test run can use an earlier run's module outputs in its `variables` block.
Test providers can also use earlier run outputs. Cleanup runs in reverse `run`
block order, and failed cleanup writes a state file for finding and removing
remaining resources. Read module outputs before a run destroys that module.

### Experimental tooling

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. Create saved plans using symbol libraries with
1.13.2 or later; 1.13.10 enables planning when modules use them and fixes a crash
when a symbol library is uninitialized.

Files in this skill

  • SKILL.md9 KB
  • coverage.json1 KB
  • references/cli-automation-and-libraries.md4 KB
  • references/encryption.md5.5 KB
  • references/language-modules-and-lifecycle.md7 KB
  • references/state-backends-and-installation.md6 KB
  • references/testing.md1.8 KB
  • references/upgrade-security-and-platforms.md3.5 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.