Registry / devops / tf-output

tf-output

JSON →
library1.8.3jsnpmunverified

CLI tool to fetch Terraform outputs and expose them as environment variables or print to stdout in various formats. Current stable version 1.8.3, last updated in 2021. Allows running commands with Terraform outputs injected, exporting to shell, and supports path templates, auto-init, and plan checking. Compared to manual terraform output parsing, it provides a unified interface across multiple Terraform directories and modules.

npm install tf-output
INSTALL
IMPORT
SIG · TF-OUTPUT
T
tf-output
devopsjavascriptv1.8.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI (package)
npm install -g tf-output # then: tf-output <dir>
npm install tf-output --save-dev # no programmatic API
This is a CLI tool, not a library. Install globally or use npx.

Demonstrates installing tf-output globally and various CLI usage patterns including direct output, environment injection, and path templating.

#!/usr/bin/env bash # Install globally npm install -g tf-output # Assuming terraform outputs exist in terraform/database directory tf-output database # Run command with outputs as environment variables tf-output database -- node -e "console.log(process.env.DATABASE_URL)" # Export to current shell export $(tf-output database) # Use path template with custom variables tf-output database -p '{stage}/{region}/terraform/{dir}' --stage=prod --region=us-east-1 # Auto-init terraform before fetching outputs tf-output database -a # Check plan for unapplied changes tf-output database -c
Debug
Known issues
deprecatedThe package has not been updated since 2021 and may not support newer Terraform versions or CLI changes.
fix
Consider alternatives like terraform output -json parsing manually with jq.
affects: >=1.0.0
gotchaThe tool expects terraform to be initialized locally in each target directory. Without -a flag, it fails silently if terraform is not initialized.
fix
Use -a flag for auto-init or manually run terraform init in each directory.
affects: All
gotchaPath template substitution requires all variables to be provided or they are passed through literally, potentially causing errors.
fix
Ensure all template variables (e.g., {stage}, {region}) are supplied via command-line arguments.
affects: All
gotchaThe tool does not support programmatic API; it's CLI-only. Node.js require will not work.
fix
Use child_process.exec or execSync to invoke tf-output from Node.js code.
affects: All
Errors
Common errors & fixes
tf-output: command not found
Package not installed globally or npx not used.
fix
Run: npm install -g tf-output
Error: No outputs found in module
Terraform has not been applied or outputs are not defined.
fix
Run terraform apply in the target directory first, ensure outputs are defined in Terraform configuration.
Error: Terraform not initialized in /path/to/terraform/dir
Missing terraform init. Auto-init not enabled.
fix
Use -a flag or run terraform init manually in the directory.
Upgrade
Version history
1.8.3latest on npm
Audit
Dependencies
commanderrequiredCLI argument parsing
Agent activity
6 hits · last 30 days
node
6
Resources
tf-output — npm install tf-output · libregistry