terraform

Manages infrastructure as code with Terraform and OpenTofu modules, state, and providers.

22|Updated Sep 10, 2026
One-click install
npx skills add https://github.com/Lynricsy/HyperSkills --skill terraform-lynricsy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform
Source: https://github.com/Lynricsy/HyperSkills/tree/main/skills/terraform
Command: npx skills add https://github.com/Lynricsy/HyperSkills --skill terraform-lynricsy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing and reviewing Terraform or OpenTofu configuration involves subtle failure modes—resource identity churn from count, secrets persisting in plaintext state, drift between configuration and reality, and version gates that differ between the two runtimes—that cause outages and security leaks when missed. ## Core Features & Use Cases - Refactoring without destruction: Migrate copy-pasted configurations into modules using moved blocks and for_each, with a zero-destroy plan as the acceptance gate. - State reconciliation and splitting: Adopt hand-made infrastructure with import blocks, retire objects with removed blocks, and split oversized state by blast radius. - Testing and review: Write .tftest.hcl suites that run without cloud credentials, and review changes against plan output with findings ordered by blast radius. - Use Case: Given a legacy network file duplicated across three environments, refactor it into one reusable module with per-environment callers while guaranteeing Terraform destroys and recreates nothing. ## Quick Start Use the terraform skill to refactor my legacy_network.tf into a reusable module without destroying any existing infrastructure.

Frequently Asked Questions about terraform

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Terraform code into modules without destroying resources?

Use `moved` blocks for every address that changes, written in the same commit as the move, and verify with `terraform plan` reporting zero creates and zero destroys. Migrate `count` to `for_each` with keyed collections so removing an element does not renumber other instances.

Should I use count or for_each in Terraform?

Use `for_each` for any collection whose membership can change, because `count` addresses instances by list index and removing an element renumbers everything after it. Keep `count` only for the zero-or-one boolean toggle like `count = var.enabled ? 1 : 0`.

What is the difference between Terraform and OpenTofu features?

OpenTofu forked from Terraform 1.5 and they have diverged: OpenTofu offers client-side state encryption and provider `for_each`, while Terraform has Stacks, list resources, and actions. Shared features like mock providers arrived at different versions (Terraform 1.7, OpenTofu 1.8), so version gates must name the runtime.

Does sensitive = true keep secrets out of Terraform state?

No, `sensitive = true` only masks values in CLI output while the value remains in state in plaintext. Use ephemeral variables (Terraform 1.10+/OpenTofu 1.11+), write-only `*_wo` arguments, or keep the secret outside Terraform entirely.

How do I write Terraform tests that run without cloud credentials?

Write `.tftest.hcl` files with `command = plan` run blocks asserting on values derived from inputs, and use `expect_failures` for validation rejection paths. Modules depending only on `hashicorp/local` or `terraform_data` need no credentials or mock providers at all.

Why does for_each fail with Invalid for_each argument?

The error occurs when `for_each` keys derive from another resource's computed attributes, which are unknown at plan time, and `depends_on` does not fix it. Drive keys from input variables or static locals and index the computed values by those keys instead.