Terraform
Read Terraform and OpenTofu state via CLI and marshal into swamp data.
Shells out to terraform show -json (or tofu show -json) to read state
from any configured backend, then writes swamp resources keyed by Terraform
resource address for CEL consumption in workflows and reports.
Supports workspace selection and binary switching between Terraform and OpenTofu via global arguments.
Quick Start
swamp extension pull @webframp/terraform
swamp model create @webframp/terraform tf-infra \
--global-arg workDir=/path/to/terraform/repo2026.08.28.1
Changed: Normalized the extension license to Apache-2.0 and corrected the copyright holder to "Sean Escriva". Extensions that previously shipped an MIT LICENSE.md are now Apache-2.0, consistent with the repository root and every other extension. No code or behavioral changes.
Upgrade note: License text only. No API, schema, or runtime behavior changed.
2026.08.26.3
Fixed: Restored inline npm:zod@4.4.3 import specifiers so the registry
quality scorer can resolve dependencies and score the extension. An earlier
release used a bare "zod" import-map specifier, which published but scored as
unscored.
Changed: Retained explicit compilerOptions.strict in deno.json. No
behavioral or schema changes.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| workDir | string | Path to the initialized Terraform/OpenTofu working directory |
| workspace | string | Terraform workspace name |
| binary | string | CLI binary to use: 'terraform' or 'tofu' |
Resources
2026.08.26.3
Fixed: Restored inline npm:zod@4.4.3 import specifiers so the registry
quality scorer can resolve dependencies and score the extension. An earlier
release used a bare "zod" import-map specifier, which published but scored as
unscored.
Changed: Retained explicit compilerOptions.strict in deno.json. No
behavioral or schema changes.
2026.08.26.1
Fixed: Added missing description field to upgrade entry for version
2026.08.24.2. The omission caused swamp extension pull to fail with a catalog
validation error ("upgrades.N.description: Invalid input: expected string,
received undefined").
2026.08.24.3
Added: Output metadata attributes for observability.
durationMs: Method execution duration in milliseconds.collectedBy: Extension name that produced the data.fetchedAt: ISO 8601 timestamp when data was fetched (added to resources that previously lacked it).
2026.08.24.2
Added Troubleshooting section documenting no CLI timeout, empty-state handling, binary validation gap, workDir validation timing, sequential resource writes, and TF_WORKSPACE behavior.
2026.08.21.2
Changed: CLI failures from runTfCommand now say what was being run and
where. Previously, if terraform/tofu couldn't be spawned at all (not
installed, not on PATH), the raw OS error propagated alone with no
indication of the command or working directory involved. A non-zero exit now
reports the exit code alongside stderr, and unparseable JSON output from
show -json is now reported as a JSON-parse failure naming the command and
working directory, instead of a bare SyntaxError.
2026.08.21.1
Changed: Tightened workDir on the global-args schema to require a
non-empty string. It's a required filesystem path the CLI shells out
against — an empty value never resolved to a usable Terraform/OpenTofu
working directory, so this catches misconfiguration at model-create time.
2026.08.20.1
Upgrade note: Bumped zod from 4.3.6 to 4.4.3. No behavioral changes — dependency version alignment only.
2026.08.21.1
Changed: Tightened workDir on the global-args schema to require a
non-empty string. It's a required filesystem path the CLI shells out
against — an empty value never resolved to a usable Terraform/OpenTofu
working directory, so this catches misconfiguration at model-create time.
2026.08.20.1
Upgrade note: Bumped zod from 4.3.6 to 4.4.3. No behavioral changes — dependency version alignment only.
2026.08.20.1
Upgrade note: Bumped zod from 4.3.6 to 4.4.3. No behavioral changes — dependency version alignment only.
2026.07.18.1
Added: An upgrades array entry (no-op) to terraform.ts for proper typeVersion tracking on existing instances. No schema or behavior changes.
2026.07.16.1
Changed: README and LICENSE reformatted (deno fmt) in PR #134; this is the first version bump to publish that formatting to the registry. No functional or behavioral change.
2026.07.16.1
Changed: README and LICENSE reformatted (deno fmt) in PR #134; this is the first version bump to publish that formatting to the registry. No functional or behavioral change.
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned