CLI Overview
TFx CLI commands let you interact with HCP Terraform and Terraform Enterprise from scripts, CI/CD pipelines, and the terminal. Each command follows the pattern:
tfx <resource> <action> [flags]For example:
tfx workspace listtfx workspace show -w my-workspacetfx variable list -w my-workspaceEnvironment variables and flags
Profiles are the recommended approach, but you can also configure TFx with environment variables or flags directly. These take precedence over profile values.
| Flag | Environment Variable | Default |
|---|---|---|
--hostname | TFE_HOSTNAME | app.terraform.io |
--organization | TFE_ORGANIZATION | (none) |
--token | TFE_TOKEN | (none) |
This is useful in CI/CD pipelines where you set credentials via environment variables rather than a config file.
See Getting Started — Configuration precedence for the full resolution order when multiple sources are configured.
Output
CLI commands output a formatted table by default. Add --json (or -j) to get machine-readable JSON for scripting and CI pipelines.
$ tfx variable list -w tfx-test╭──────────────────────┬───────────┬──────────────┬───────────┬───────┬───────────┬──────────────────────╮│ ID │ KEY │ VALUE │ SENSITIVE │ HCL │ CATEGORY │ DESCRIPTION │├──────────────────────┼───────────┼──────────────┼───────────┼───────┼───────────┼──────────────────────┤│ var-7XYNuuo4tMjXeXG4 │ variable7 │ {"a":"1"...} │ false │ true │ terraform │ I am a map in a file ││ var-MJaLJ7czxKuU48eu │ variable3 │ It is friday │ false │ false │ env │ I am environmental │╰──────────────────────┴───────────┴──────────────┴───────────┴───────┴───────────┴──────────────────────╯$ tfx variable list -w tfx-test --json | jq '.[].Key'"variable7""variable3"