Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Terraform Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-terraform-knowledge-patch)
---
name: terraform-knowledge-patch
description: Terraform / OpenTofu
version: null
license: MIT
metadata:
author: Nevaberry
---
# Terraform and OpenTofu compatibility
Load this skill when upgrading Terraform or OpenTofu configurations, working
with state and imports, configuring backends, writing tests, implementing
providers, or using Terraform Stacks and HCP Terraform. Use the topic references
for complete examples, product distinctions, and version-specific behavior.
> [!CAUTION]
> Prerelease guidance may change before stable release. The references mark
> prerelease items and identify experimental and alpha-only behavior.
## Reference index
| Reference | Topics |
| --- | --- |
| [Backends, encryption, and security](references/backends-encryption-and-security.md) | Backend migrations, credentials, locking, encryption, installation, platforms, security fixes |
| [CLI, automation, and output](references/cli-automation-and-output.md) | Initialization, provider locks, JSON, plan selection, queries, policies, console, graphs |
| [Language and modules](references/language-and-modules.md) | Module sources, types, validation, functions, providers, sensitivity, ephemeral values, write-only arguments |
| [Provider Plugin Framework](references/provider-plugin-framework.md) | Function APIs, schemas, plan modifiers, identity, ephemeral resources, list resources, actions, state stores |
| [Stacks and HCP Terraform](references/stacks-and-hcp.md) | Components, deployments, policies, CLI, VCS, agents, registry publishing, migration, usage |
| [State, import, and refactoring](references/state-import-and-refactoring.md) | Removal, destroy protection, replacement, cross-type moves, identity imports, generated configuration, actions |
| [Testing](references/testing.md) | Inputs, providers, mocks, overrides, state, concurrency, teardown, reports, diagnostics |
## Upgrade changes and deprecations
### Backend migrations
OpenTofu 1.8 removes `use_legacy_workflow`: remove it from the S3 backend block
and any `-backend-config` inputs. Terraform 1.10 removes deprecated top-level
S3 role-assumption settings; move them into `assume_role` in the backend.
OpenTofu's PostgreSQL backend locking scheme in 1.10 is incompatible with older
clients. Upgrade all clients using that database together or move them to
separate databases; mixing versions can allow conflicting writes. Use separate
`table_name` and `index_name` values for configurations using different tables.
For the OpenTofu AzureRM backend upgrade, remove `endpoint`, `ARM_ENDPOINT`,
and `msi_endpoint`; replace `ARM_MSI_ENDPOINT` with `MSI_ENDPOINT`; choose at
most one of `environment` and `metadata_host`. Run `tofu init -reconfigure` in
an existing working directory to load the updated settings.
Terraform's S3 endpoint flags `AWS_USE_FIPS_ENDPOINT` and
`AWS_USE_DUALSTACK_ENDPOINT` require literal `true` or `false`; a nonempty
string such as `1` no longer enables them.
### Configuration and command compatibility
When `main.tofu` and `main.tf` share a directory, OpenTofu loads `main.tofu`
and skips the entire `main.tf`. Put declarations OpenTofu still needs in
`main.tofu` or a different configuration file.
Terraform's `-state` flag is deprecated for `plan`, `apply`, and `refresh`.
Set `path` in the `local` backend to select the state file.
An import targeting a nonexistent module causes a Terraform error. Fix or
remove these blocks before upgrading. An import whose target was already
deleted no longer blocks a destroy operation.
Terraform checks filesystem function results for consistency during apply.
Keep files used by those expressions stable from plan through apply.
Terraform 1.13.5 allows changes in provider configurations and fixes false
`templatefile` consistency errors involving impure functions.
OpenTofu's `issensitive` returns unknown for an unknown argument. Base `count`
or `for_each` on a value known at plan time if those arguments previously
depended on the sensitivity of an unknown value.
### Tests, installation, and transport
Move provider version constraints from `.tftest.hcl` provider blocks into
`required_providers` in the configuration under test. Declare complex external
test inputs with `variable` blocks when upgrading to Terraform 1.13;
declarations are optional, but omitting them can produce diagnostics.
Terraform 1.15.4 blocks provider installation into symlinked directories.
Use a real directory as the installation destination. Terraform 1.15.9
mitigates CVE-2026-14978: upgrade if `.terraformignore` excludes files from
HCP Terraform or Terraform Enterprise uploads, because Unicode normalization
could cause excluded files to be uploaded.
Provisioners honor `bastion_host_key`; verify it matches the bastion's host key
before upgrading. OpenTofu 1.12 warns on `type = "winrm"` in `file` and
`remote-exec` provisioners; removal is planned for 1.13. Migrate those
connections to OpenSSH for Windows.
Terraform 1.16.7 and 1.17.0 drop trust for TLS chains through the compromised
intermediate CAs identified in CVE-2026-111943. Affected endpoints need a
trusted replacement chain. See the backend and security reference for other
security fixes and operating-system requirements.
## State, imports, and resource lifecycle
Terraform 1.7 records input validation results in state again. When a
configuration in the 1.3, 1.4, or 1.5 series reads that state, including through
`terraform_remote_state`, use at least 1.3.10, 1.4.7, or 1.5.7 respectively.
Replace a module block with a `removed` block containing `destroy = false`
to drop its resources from state while keeping infrastructure. Review the
removal in the plan before applying, including in VCS-driven workspaces.
A resource's `lifecycle.destroy = false` prevents Terraform from destroying
the resource. OpenTofu's setting drops the object from state and leaves the
remote object in place; `tofu destroy -suppress-forget-errors` allows successful
exit when intentionally forgetting resources.
A Terraform cross-type `moved` block requires conversion support from the
target resource's provider. Check the target provider's supported type pairs.
Supported moves can also cross providers. OpenTofu supports cross-type moves
for supported type pairs.
An identity-based Terraform `import` requires a resource type supporting it;
set exactly one of `identity` or `id`. An import's `for_each` cannot reference
the target resource. Build the collection from an independent input, local,
or data source. Import blocks can live in the child module declaring the
resource; separate blocks can target different instances of one resource.
Terraform actions use top-level `action` blocks and can be triggered through
a resource lifecycle or invoked with `-invoke`. Resource action triggers
support `on_failure` modes `halt`, `taint`, and `continue`, plus
`before_destroy` and `after_destroy` events.
## Secrets, encryption, and module inputs
Terraform reads ephemeral resources anew in each evaluation phase and keeps
their values out of saved plans and state. Inputs and child-module outputs
can declare `ephemeral = true`; `ephemeralasnull` replaces ephemeral parts
with ordinary nulls while preserving the type and non-ephemeral parts.
Provider-defined write-only arguments accept ephemeral or ordinary values
and omit them from saved plans and state. Increment the provider's separate
version argument, when available, to make rotation visible in the plan and
trigger the update. The language reference includes provider-specific fields
and the complete generated-password rotation example.
OpenTofu supports ephemeral inputs, child-module outputs, ephemeral resources,
and managed-resource write-only arguments. Its encryption configuration lives
under `terraform.encryption`. For plaintext migration, retain an `unencrypted`
fallback, run `tofu apply` to rewrite state, then remove the fallback and set
`enforced = true`. Keep the old method and key provider available through
`fallback` during key rotation until the rewrite succeeds.
For encrypted remote state, the consuming OpenTofu project needs the producer's
decryption method and key provider with the same provider type, name, and
access to the original key. Supply encryption variables again when applying
a saved plan; non-ephemeral inputs must match their plan-time values.
Terraform module `source` and registry `version` expressions can use inputs
declared with `const = true` and locals resolvable during initialization.
Supply inputs to `terraform init` with `-var` or `-var-file`. OpenTofu permits
input variables and locals in module sources, registry versions, and backend
settings; they must resolve before resource, data source, and child-module
outputs are available.
## Tests and automation
Set `override_during = plan` in Terraform mocks or overrides for plan runs;
the default is `override_during = apply`. Mock aliases let a test select real
or mock provider configurations, while overrides can target individual managed
resources, data sources, or child-module instances.
Use `state_key` to select a Terraform test run's state: equal keys share state,
different keys separate it. Opt into `parallel = true` at test or run level.
Runs can overlap when they use separate state and neither depends on the
other's outputs. `terraform test -parallelism=4` limits concurrent operations
within each run's plan or apply.
`terraform test` ignores `lifecycle.prevent_destroy` during cleanup. Alpha
builds support a run-level `backend`, `skip_cleanup`, saved cleanup state and
manifests under `.terraform`, and `terraform test cleanup` to retry cleanup.
Use `terraform test -junit-xml=test-results.xml` for CI reports. File-level
errors appear in skipped test elements. `terraform test -verbose` shows
expected diagnostics, including those checked with `expect_failures`.
In plan JSON, `applyable` indicates whether automation should offer apply;
`complete` indicates whether apply is expected to reach the desired state.
If `complete` is present and false, plan and apply again toward convergence.
Define Terraform `list` blocks in `*.tfquery.hcl`; `terraform query` displays
matches and can generate import configuration. `terraform validate -query`
checks query files offline. In Terraform 1.17.0, `plan`, `apply`, and `query`
accept `-policies` in standard builds without `-allow-experimental-features`.
OpenTofu's `tofu plan -exclude=kubernetes_manifest.crds` skips the selected
resource and everything depending on it. `-json-into=FILENAME` writes the same
data as `-json` separately while retaining human-readable stdout.
## Provider development and Stacks
Implement Framework state moves on the destination resource with
`resource.ResourceWithMoveState`. For write-only attributes, use
`WriteOnly: true` with `Required: true` or `Optional: true`, leaving `Computed`
false. Read values from request configuration; prior, planned, and final state
carry null. Consult the Framework reference for nested-schema restrictions.
Framework identity imports supply `req.Identity` and an empty `req.ID`;
CLI imports and ID-based import blocks still use string IDs. Populate identity
during `Create`, `Read`, and `Update`. Experimental deferral requires checking
`ClientCapabilities` before setting `Deferred` and a compatible prerelease
Terraform client.
Stacks declare module `component` blocks in `.tfcomponent.hcl` and deployments
in `.tfdeploy.hcl`. Each deployment uses its own inputs and isolated state.
GA deployment groups replace beta orchestration rules; custom groups with
auto-approval checks require HCP Terraform Premium. The Stacks reference covers
linked dependencies, agents, registry publishing, and workspace migration.