hcpctl
A CLI for HCP Terraform (formerly Terraform Cloud/Enterprise)
hcpctl get ws # List all workspaces
hcpctl get ws my-workspace # Get specific workspace
hcpctl get prj -o yaml # List projects as YAML
hcpctl get org # List organizations
Features
| Command | Resources | Capabilities |
|---|---|---|
get | oc | List/filter OAuth clients (VCS connections) |
org-member | List/filter organization members by email/status | |
org | List/filter organizations | |
prj | List/filter/sort projects, show workspace counts/names/IDs | |
run | List active runs (non-final states), filter by status/workspace, fetch subresources (events, plan, apply), stream/download logs | |
team | List/filter teams in organization | |
ws | List/filter/sort workspaces, group by org/project, fetch subresources (current-run, current-state-version, current-configuration-version, current-assessment-result) | |
logs | — | View plan/apply logs for run or workspace's current run, follow in real-time |
watch | ws | Continuously monitor workspace for new runs, auto-stream logs |
invite | — | Invite user to organization, optionally assign to teams |
delete | org-member | Remove user from organization (by ID or email) |
purge | run | Cancel/discard pending runs blocking a workspace |
state | Zero out all resources from workspace state (with mandatory confirmation) | |
update | — | Self-update to latest version |
Output formats: table (default), json, yaml, csv
Global options: --host, --token, --batch (no prompts/spinners), --no-header
Documentation
For complete command reference, see Command Line Help.
hcpctl --help # General help
hcpctl get --help # Get command help
hcpctl get ws --help # Workspace-specific options
Installation
Linux / macOS
curl -fsSL \
https://raw.githubusercontent.com/pkodzis/hcpctl/main/scripts/install.sh | bash
Or with custom install directory:
INSTALL_DIR=/usr/local/bin \
curl -fsSL \
https://raw.githubusercontent.com/pkodzis/hcpctl/main/scripts/install.sh | bash
Windows (PowerShell)
Invoke-RestMethod `
https://raw.githubusercontent.com/pkodzis/hcpctl/main/scripts/install.ps1 `
| Invoke-Expression
From Source
Requires Rust:
git clone https://github.com/pkodzis/hcpctl.git
cd hcpctl
cargo install --path .
Configuration
Set your HCP Terraform token:
export TFE_TOKEN="your-token-here"
Optionally set default host and organization:
export TFE_HOST="app.terraform.io"
export TFE_ORG="my-organization"
Or use Terraform CLI credentials file (~/.terraform.d/credentials.tfrc.json).
Run hcpctl get --help for full credential resolution details.
Development Environment
Prerequisites
Linux / macOS (Development)
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Verify installation
rustc --version
cargo --version
# Install development tools
cargo install cross # Cross-compilation support
cargo install cargo-edit # Adds `cargo add`, `cargo upgrade` commands
cargo add clap-markdown # for building CLI command reference
cargo install mdbook # for building html doc
Windows
# Install Rust toolchain from https://rustup.rs
# Download and run rustup-init.exe
# Verify installation (in new terminal)
rustc --version
cargo --version
# Install development tools
cargo install cross
cargo install cargo-edit
Build & Test
# Clone the repository
git clone https://github.com/pkodzis/hcpctl.git
cd hcpctl
# Install pre-commit hooks
pip install pre-commit
pre-commit install
pre-commit install --hook-type pre-push
# Build
cargo build
# Run tests
cargo test
License
Getting Started with hcpctl
hcpctl is a command-line interface for HCP Terraform (formerly Terraform Cloud) and Terraform Enterprise, designed to feel familiar to users of kubectl.
Installation
You can install hcpctl using the provided installation scripts:
Linux / macOS:
curl -sSL https://hcpctl.com/install.sh | bash
Windows (PowerShell):
irm https://hcpctl.com/install.ps1 | iex
First Steps
Before you can use hcpctl, you need to authenticate with HCP Terraform.
The recommended way is to use the standard Terraform CLI authentication. If you have terraform installed, simply run:
terraform login
This will open your browser, generate an API token, and save it to ~/.terraform.d/credentials.tfrc.json. hcpctl will automatically read this file and use the token.
Alternatively, you can set the HCP_TOKEN environment variable directly:
export HCP_TOKEN="your-terraform-cloud-token"
You can also use TFC_TOKEN or TFE_TOKEN.
Tip: You can generate a token manually in the HCP Terraform UI under User Settings -> Tokens.
Basic Usage
The core command pattern is hcpctl <verb> <resource> [name] [flags].
Listing Resources
To list all organizations you have access to:
hcpctl get org
To list workspaces in a specific organization:
hcpctl get ws --org my-organization
Getting Specific Resources
To get details about a specific workspace:
hcpctl get ws my-workspace --org my-organization
Output Formats
Like kubectl, you can change the output format using the -o or --output flag. Supported formats are table (default), json, yaml, and csv.
hcpctl get ws my-workspace --org my-organization -o yaml
Next Steps
- Learn more about Authentication and Contexts to manage multiple environments.
- Use Contexts and Multi-Environment Workflows for production/dev setup patterns.
- Explore Workspace Management to see how to organize your infrastructure.
- See Runs and Logs to learn how to monitor Terraform executions.
Authentication and Contexts
hcpctl needs to know which HCP Terraform / Terraform Enterprise host to connect to, and what API token to use. It supports multiple ways to provide these credentials.
Resolution Order
When you run a command, hcpctl resolves the Host and Token in the following order (first match wins):
Host Resolution
- CLI argument (
-Hor--host) - Environment variable (
TFE_HOSTNAME) - Active Context
- Terraform Credentials file (
~/.terraform.d/credentials.tfrc.json)
Token Resolution
- CLI argument (
-tor--token) - Environment variables (
HCP_TOKEN,TFC_TOKEN,TFE_TOKEN) - Active Context
- Terraform Credentials file (
~/.terraform.d/credentials.tfrc.json)
Using Contexts
If you work with multiple organizations or multiple Terraform Enterprise instances, Contexts are the best way to manage your configuration. They work exactly like kubectl contexts.
Creating a Context
You can create a context that stores your host, token, and default organization:
hcpctl config set-context prod \
--host app.terraform.io \
--token $HCP_TOKEN \
--org my-production-org
Switching Contexts
To use a context, set it as the current context:
hcpctl config use-context prod
Now, any command you run will automatically use the host, token, and organization from the prod context. You no longer need to pass --org my-production-org to every command!
Managing Contexts
List all configured contexts:
hcpctl config get-contexts
Show the currently active context:
hcpctl config current-context
Delete a context:
hcpctl config delete-context prod
Show full raw config:
hcpctl config view
Select context for a single command:
hcpctl --context prod get ws
You can also set context via environment variable:
export HCPCTL_CONTEXT=prod
Active context name resolution order is:
--contextHCPCTL_CONTEXTcurrent-contextin hcpctl config file
Terraform Credentials File
If you already use the standard terraform CLI, you likely have a credentials file at ~/.terraform.d/credentials.tfrc.json (or %APPDATA%\terraform.d\credentials.tfrc.json on Windows).
hcpctl automatically reads this file. If you only have one host configured in it, hcpctl will use it automatically. If you have multiple hosts, hcpctl will prompt you to select one interactively.
In --batch mode, interactive host selection is disabled. If multiple hosts exist and none was explicitly provided (--host, TFE_HOSTNAME, context), command fails with an error.
Related guides
Contexts and Multi-Environment Workflows
If you work with multiple HCP Terraform or Terraform Enterprise environments (for example: dev, stage, prod), contexts are the safest way to avoid using the wrong host/org/token.
Why and when to use
Use contexts when you:
- switch between multiple hosts,
- use different default organizations,
- want shorter commands without repeating
--host,--token,--org.
Common tasks
1. Create contexts
hcpctl config set-context dev --host app.terraform.io --org my-dev-org
hcpctl config set-context prod --host tfe.company.internal --org my-prod-org
You can include token directly:
hcpctl config set-context prod --token "$TFE_TOKEN"
2. Switch active context
hcpctl config use-context dev
hcpctl config current-context
3. List configured contexts
hcpctl config get-contexts
4. Use one-off context override
hcpctl --context prod get ws
Advanced variants
Environment-driven context selection
export HCPCTL_CONTEXT=prod
hcpctl get run --org my-prod-org
Active context name is resolved in this order:
--contextHCPCTL_CONTEXTcurrent-contextin config
Safe defaults + explicit overrides
Keep default org in context, but override for one command:
hcpctl --context prod get ws --org emergency-org
Pitfalls and troubleshooting
"Why did command use wrong host?"
Host resolution order is:
--hostTFE_HOSTNAME- active context host
- Terraform credentials file
If behavior is unexpected, check env vars first:
env | grep -E 'HCPCTL_CONTEXT|TFE_HOSTNAME|HCP_TOKEN|TFC_TOKEN|TFE_TOKEN'
Multiple hosts in credentials file + batch mode
In normal mode, hcpctl may ask you to choose host interactively.
In --batch mode, no prompt is shown. If multiple hosts are available and host is not explicitly set, command fails.
Context missing after deletion
If you delete the current context, current-context becomes empty. Set a new one:
hcpctl config use-context dev
Related guides
Managing Workspaces and Projects
Workspaces are the core resource in HCP Terraform. hcpctl provides powerful tools to list, filter, and modify workspaces and their associated projects.
Listing and Filtering Workspaces
You can list all workspaces in an organization:
hcpctl get ws --org my-org
Filtering
Use the -f or --filter flag to search for workspaces by name. This performs a partial match:
hcpctl get ws -f "network" --org my-org
Sorting
You can sort the output using the -s or --sort flag. For workspaces, available sort fields are:
nameresourcesupdated-attf-versionpending-runs(requires--has-pending-runs)
Use -r to reverse the sort order.
hcpctl get ws --sort updated-at -r --org my-org
To focus only on workspaces blocked by queued runs:
hcpctl get ws --org my-org --has-pending-runs --sort pending-runs -r
Workspace Subresources
You can fetch specific subresources of a workspace using the --subresource flag. This is useful for getting the current state version, current run, or configuration version.
Supported values are:
runstateconfigassessment
--subresource works only with a single workspace (hcpctl get ws <NAME_OR_ID>) and JSON/YAML output.
hcpctl get ws my-workspace --org my-org --subresource state -o yaml
Downloading Configuration
If you need to inspect the actual Terraform code that is currently loaded into a workspace (the Configuration Version), you can download it directly:
hcpctl download config my-workspace --org my-org
This will download the .tar.gz archive containing the Terraform configuration files that were uploaded for the current run.
Modifying Workspaces
The set command allows you to modify workspace properties.
Moving a Workspace to a Project
To move a workspace to a different project:
hcpctl set ws my-workspace --prj "Core Infrastructure" --org my-org
You can also update Terraform version in the same command:
hcpctl set ws my-workspace --terraform-version 1.12.2 --org my-org
Managing Tags
Tags in HCP Terraform are managed as separate bindings. You can get, set, and delete tags on workspaces and projects.
Viewing Tags
hcpctl get tag ws my-workspace --org my-org
Adding Tags
You can add multiple tags at once. Tags are positional arguments (space-separated), not a --tags flag.
Workspaces support mixed tag types:
- flat tags:
env - key-value bindings:
team=platform
hcpctl set tag ws my-workspace env team=platform --org my-org
Removing Tags
hcpctl delete tag ws my-workspace env team --org my-org
For projects, only key=value tags are supported:
hcpctl set tag prj my-project env=prod owner=platform --org my-org
Purging State (Danger Zone)
If you need to completely reset a workspace's state (making Terraform "forget" all resources without destroying them in the cloud provider), you can use the purge state command.
This requires the exact Workspace ID (ws-...) to prevent accidental deletion.
hcpctl purge state ws-1234567890abcdef
Note: To bypass the interactive confirmation prompt, you must use the --my-resume-is-updated flag instead of the standard --batch flag.
Related guides
Runs and Logs
Monitoring and managing Terraform runs is a common task. hcpctl provides commands to view runs, stream logs, and cancel stuck runs.
Viewing Runs
To list active runs (runs that are not in a final state like applied or errored) across your organization:
hcpctl get run --org my-org
To view runs for a specific workspace:
hcpctl get run --ws ws-1234567890abcdef
--ws accepts a workspace ID (ws-...).
You can also filter by status and workspace names in org scope:
hcpctl get run --org my-org --status planning,applying
hcpctl get run --org my-org --workspace-names app-prod,network-prod
Streaming Logs
You can view logs of a specific run, or logs from the current run of a workspace.
To stream logs for a specific run ID:
hcpctl logs run-1234567890abcdef
To stream logs for the current run of a workspace (name or ws-...):
hcpctl logs my-workspace --org my-org
By default, this streams the plan logs. To stream the apply logs, use the -a or --apply flag:
hcpctl logs my-workspace --apply --org my-org
To follow output in real time, add -f / --follow:
hcpctl logs run-1234567890abcdef --follow
Watching a Workspace
If you are waiting for a workspace to trigger a run (e.g., from a VCS webhook), you can use the watch command. This will continuously monitor the workspace and automatically stream logs whenever a new run starts.
hcpctl watch ws my-workspace --org my-org
This is incredibly useful for CI/CD pipelines or when you've just pushed a commit and want to see the Terraform output immediately.
Purging Runs
Sometimes a workspace gets stuck because of a queued run that is waiting for confirmation, or a run that has hung. You can use purge run to cancel or discard all pending runs blocking a workspace.
hcpctl purge run my-workspace --org my-org
This will:
- Find all pending runs (queued, planning, etc.).
- Ask for confirmation.
- Cancel actively executing runs and discard queued runs.
You can use --dry-run to see what would be cancelled without actually doing it.
Related guides
Managing Users and Teams
hcpctl provides administrative commands to manage users, teams, and invitations within your HCP Terraform organization. This is especially useful for onboarding new team members or auditing access.
Listing Organization Members
To see all members in your organization:
hcpctl get org-member --org my-org
Filtering Members
You can filter members by their email address or their current status (active or invited):
# Find a specific user
hcpctl get org-member -f "alice@example.com" --org my-org
# List all pending invitations
hcpctl get org-member --status invited --org my-org
Managing Teams
To list all teams in your organization:
hcpctl get team --org my-org
You can also filter teams by name:
hcpctl get team -f "platform" --org my-org
Inviting Users
You can invite a new user to your organization and optionally assign them to specific teams immediately.
hcpctl invite --email new.user@example.com --org my-org
To invite a user and add them to the "Developers" and "Platform" teams:
hcpctl invite --email new.user@example.com --teams "Developers,Platform" --org my-org
--teams accepts comma-separated team references (name or ID).
Removing Users
To remove a user from the organization, you can use their email address or their membership ID (ou-...):
hcpctl delete org-member old.user@example.com --org my-org
Skip confirmation with -y/--yes (or global --batch mode):
hcpctl delete org-member old.user@example.com --org my-org --yes
Viewing VCS Connections (OAuth Clients)
When setting up workspaces that connect to version control systems (like GitHub or GitLab), you often need the OAuth Client ID. You can list all configured VCS connections in your organization:
hcpctl get oc --org my-org
This will display the names, IDs (oc-...), and the service provider (e.g., github, gitlab_hosted) for each connection.
Related guides
Command-Line Help for hcpctl
This document contains the help content for the hcpctl command-line program.
Command Overview:
hcpctl↴hcpctl get↴hcpctl get org↴hcpctl get prj↴hcpctl get ws↴hcpctl get oc↴hcpctl get run↴hcpctl get team↴hcpctl get org-member↴hcpctl get team-access↴hcpctl get tag↴hcpctl get tag ws↴hcpctl get tag prj↴hcpctl delete↴hcpctl delete org-member↴hcpctl delete tag↴hcpctl delete tag ws↴hcpctl delete tag prj↴hcpctl purge↴hcpctl purge state↴hcpctl purge run↴hcpctl download↴hcpctl download config↴hcpctl logs↴hcpctl watch↴hcpctl watch ws↴hcpctl invite↴hcpctl set↴hcpctl set ws↴hcpctl set tag↴hcpctl set tag ws↴hcpctl set tag prj↴hcpctl config↴hcpctl config set-context↴hcpctl config use-context↴hcpctl config get-contexts↴hcpctl config current-context↴hcpctl config delete-context↴hcpctl config view↴hcpctl update↴
hcpctl
Explore HCP Terraform / Terraform Enterprise resources
Usage: hcpctl [OPTIONS] <COMMAND>
HOST RESOLUTION:
The host is resolved in the following order (first match wins):
- CLI argument (-H, --host)
- Environment variable: TFE_HOSTNAME
- Active context (from --context, HCPCTL_CONTEXT env, or current-context)
- Credentials file (~/.terraform.d/credentials.tfrc.json):
- If 1 host configured: use it automatically
- If multiple hosts: interactive selection (or error in batch mode)
TOKEN RESOLUTION:
The API token is resolved in the following order (first match wins):
- CLI argument (-t, --token)
- Environment variables (in order): HCP_TOKEN, TFC_TOKEN, TFE_TOKEN
- Active context
- Credentials file (~/.terraform.d/credentials.tfrc.json) Token is read from the entry matching the resolved host.
CONTEXT:
Contexts store connection defaults (host, token, org) for quick switching:
- hcpctl config set-context prod --host app.terraform.io --org my-org
- hcpctl config use-context prod
Resolution (first match wins):
- Host: -H flag → TFE_HOSTNAME env → context → credentials file
- Token: -t flag → HCP_TOKEN/TFC_TOKEN/TFE_TOKEN env → context → credentials file
- Org: --org flag → context
EXAMPLES:
- hcpctl get org # List all organizations
- hcpctl get ws --org myorg # List workspaces in organization
- hcpctl get ws myws --org myorg # Get workspace details
- hcpctl -H app.terraform.io get ws # Use specific host
- hcpctl -c prod get ws # Use 'prod' context
Subcommands:
get— Get resources (organizations, projects, workspaces)delete— Delete resourcespurge— Purge resources (destructive operations with mandatory confirmation)download— Download resources (configuration files, etc.)logs— View logs for a run (plan or apply)watch— Watch resources for changesinvite— Invite a user to an organizationset— Set resource properties (assign workspace to project, etc.)config— Manage connection contexts for multiple TFE/HCP instancesupdate— Update hcpctl to the latest version
Options:
-
-c,--context <CONTEXT>— Use a specific named context (overrides current-context) -
-H,--host <HOST>— TFE/HCP host URL (falls back to TFE_HOSTNAME env var or credentials file) -
-t,--token <TOKEN>— API token (overrides env vars and credentials file) -
-l,--log-level <LOG_LEVEL>— Log level (error, warn, info, debug, trace)Default value:
warn -
-b,--batch— Batch mode - no interactive prompts, no spinnersDefault value:
false -
--no-header— Omit header row in table/CSV outputDefault value:
false
hcpctl get
Get resources (organizations, projects, workspaces)
Usage: hcpctl get <COMMAND>
Subcommands:
org— Get organizationsprj— Get projectsws— Get workspacesoc— Get OAuth clients (VCS connections)run— Get runs (active runs by default - non_final states)team— Get teams in an organizationorg-member— Get organization membersteam-access— Get team project access bindingstag— Get tags (org-level, workspace, or project)
hcpctl get org
Get organizations
Usage: hcpctl get org [OPTIONS] [NAME]
Command Aliases: orgs, organization, organizations
Arguments:
<NAME>— Organization name (if specified, shows details for that organization)
Options:
-
-f,--filter <FILTER>— Filter organizations by name (substring match) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
hcpctl get prj
Get projects
Usage: hcpctl get prj [OPTIONS] [NAME]
Command Aliases: prjs, project, projects
Arguments:
<NAME>— Project name or ID (if specified, shows details for that project)
Options:
-
--org <ORG>— Organization name (required for single project, optional for list) -
-f,--filter <FILTER>— Filter projects by name (substring match) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
-
-s,--sort <SORT>— Sort results by fieldDefault value:
namePossible values:
name: Sort by project name (default)workspaces: Sort by workspace count
-
-r,--reverse— Reverse sort order (descending)Default value:
false -
--no-group-org— Disable grouping by organizationDefault value:
false -
--with-ws— Include workspace information (count, names, IDs)Default value:
false -
--with-ws-names— Show workspace names column (implies --with-ws)Default value:
false -
--with-ws-ids— Show workspace IDs column (implies --with-ws)Default value:
false -
--with-ws-details— Show workspaces as "name (id)" format (implies --with-ws)Default value:
false
hcpctl get ws
Get workspaces
Usage: hcpctl get ws [OPTIONS] [NAME]
Command Aliases: workspace, workspaces
Arguments:
<NAME>— Workspace name or ID (if specified, shows details for that workspace)
Options:
-
--org <ORG>— Organization name (required for single workspace, optional for list) -
-p,--prj <PRJ>— Filter by project (name or ID) -
-f,--filter <FILTER>— Filter workspaces by name (substring match) -
-o,--output <OUTPUT>— Output format (defaults to yaml when --subresource is used)Default value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
-
-s,--sort <SORT>— Sort results by fieldDefault value:
namePossible values:
name: Sort by workspace name (default)resources: Sort by resource countupdated-at: Sort by last update timetf-version: Sort by Terraform versionpending-runs: Sort by pending runs count (requires --has-pending-runs)
-
-r,--reverse— Reverse sort order (descending)Default value:
false -
--no-group-org— Disable grouping by organizationDefault value:
false -
--group-by-prj— Enable grouping by project (can be combined with org grouping)Default value:
false -
--has-pending-runs— Only show workspaces that have runs in 'pending' status (queued behind another active run). Adds a "Pending Runs" count columnDefault value:
false -
--subresource <SUBRESOURCE>— Fetch a related subresource (run=current-run, state=current-state-version, config=current-configuration-version, assessment=current-assessment-result). Only works with single workspace lookup and JSON/YAML outputPossible values:
run: Current run (current-run)state: Current state version (current-state-version)config: Current configuration version (current-configuration-version)assessment: Current assessment result (current-assessment-result)
hcpctl get oc
Get OAuth clients (VCS connections)
Usage: hcpctl get oc [OPTIONS] [NAME]
Command Aliases: oauth-client, oauth-clients, oauthclient, oauthclients
Arguments:
<NAME>— OAuth client name or ID (if specified, shows details for that client)
Options:
-
--org <ORG>— Organization name (required for single client, optional for list) -
-f,--filter <FILTER>— Filter OAuth clients by name (substring match) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
hcpctl get run
Get runs (active runs by default - non_final states)
Usage: hcpctl get run [OPTIONS] [NAME]
Command Alias: runs
NOTE: This command shows only active (non-final) runs. Use --status to filter by specific non-final statuses (e.g. planning,applying). Completed runs (applied, errored, canceled) are not shown.
Arguments:
<NAME>— Run ID (if specified, shows details for that run)
Options:
-
--org <ORG>— Organization name (lists runs across org workspaces) -
--ws <WS>— Workspace ID (lists runs for specific workspace, must start with ws-) -
--workspace-names <WORKSPACE_NAMES>— Filter by workspace names (comma-separated, only with --org) -
--status <STATUS>— Filter by specific non-final run statuses (comma-separated). Valid values: pending, fetching, queuing, plan_queued, planning, planned, cost_estimating, cost_estimated, policy_checking, policy_override, policy_soft_failed, policy_checked, confirmed, post_plan_running, post_plan_completed, applying, apply_queued -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
-
--subresource <SUBRESOURCE>— Fetch a related subresource (events, plan, apply). Requires run IDPossible values:
events: Run events (run-events)plan: Plan details with log accessapply: Apply details with log access
-
--get-log— Download and display the full log (requires --subresource plan or apply)Default value:
false -
--tail-log— Tail the log in real-time until completion (requires --subresource plan or apply)Default value:
false -
--raw— Output raw log without parsing (default: extract @message from JSON lines)Default value:
false -
-s,--sort <SORT>— Sort results by field (default: created-at, newest first)Default value:
created-atPossible values:
created-at: Sort by creation time (default: newest first)status: Sort by statusws-id: Sort by workspace ID
-
-r,--reverse— Reverse sort orderDefault value:
false -
-y,--yes— Skip confirmation prompt when results exceed 100Default value:
false
hcpctl get team
Get teams in an organization
Usage: hcpctl get team [OPTIONS] [NAME]
Command Alias: teams
Arguments:
<NAME>— Team name or ID (if specified, shows details for that team)
Options:
-
--org <ORG>— Organization name (required) -
-f,--filter <FILTER>— Filter teams by name (substring match) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
hcpctl get org-member
Get organization members
Usage: hcpctl get org-member [OPTIONS] [ID]
Command Aliases: org-members, orgmember, orgmembers
Arguments:
<ID>— Membership ID (ou-xxx) - if specified, shows details for that membership
Options:
-
--org <ORG>— Organization name (if not specified, lists members from all organizations) -
-f,--filter <FILTER>— Filter by email (substring match) -
--status <STATUS>— Filter by status (active, invited) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
hcpctl get team-access
Get team project access bindings
Usage: hcpctl get team-access [OPTIONS] [NAME]
Command Aliases: team-accesses, teamaccess, teamaccesses, ta
Arguments:
<NAME>— Team name to filter by, or a tprj- ID to fetch a single binding directly. Examples: "my-team" (requires --org), "tprj-NEQHetgHNaDKeH9s" (no --org needed)
Options:
-
--org <ORG>— Organization name (required) -
-p,--prj <PRJ>— Filter by project (name or ID) -
-f,--filter <FILTER>— Filter results by team name, project name, or access level (substring match) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
-
-s,--sort <SORT>— Sort results by fieldDefault value:
teamPossible values:
team: Sort by team name (default)project: Sort by project nameaccess: Sort by access level
-
-r,--reverse— Reverse sort order (descending)Default value:
false
hcpctl get tag
Get tags (org-level, workspace, or project)
Usage: hcpctl get tag [OPTIONS] [NAME] tag <COMMAND>
Command Alias: tags
Subcommands:
ws— Get tags on a workspaceprj— Get tags on a project
Arguments:
<NAME>— Tag name (shows/filters a specific tag at org level)
Options:
-
--org <ORG>— Organization name (required for org-level listing; optional for per-resource) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
-
-f,--filter <FILTER>— Filter tags by name (org-level only)
hcpctl get tag ws
Get tags on a workspace
Usage: hcpctl get tag ws <WORKSPACE>
Command Aliases: workspace, workspaces
Arguments:
<WORKSPACE>— Workspace name or ID (ws-xxx)
hcpctl get tag prj
Get tags on a project
Usage: hcpctl get tag prj <PROJECT>
Command Aliases: project, projects
Arguments:
<PROJECT>— Project name or ID (prj-xxx)
hcpctl delete
Delete resources
Usage: hcpctl delete <COMMAND>
Subcommands:
org-member— Delete organization member (remove from organization)tag— Delete tag bindings from a workspace or project
hcpctl delete org-member
Delete organization member (remove from organization)
Usage: hcpctl delete org-member [OPTIONS] <ID>
Command Aliases: org-members, orgmember, orgmembers
Arguments:
-
<ID>— Membership ID (ou-xxx) or email address to deleteou-xxx Membership ID - deletes directly email Email address - requires --org to identify the membership
Options:
-
--org <ORG>— Organization name (required when argument is an email) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl delete tag
Delete tag bindings from a workspace or project
Usage: hcpctl delete tag <COMMAND>
Command Alias: tags
Subcommands:
ws— Delete tags from a workspaceprj— Delete tags from a project
hcpctl delete tag ws
Delete tags from a workspace
Usage: hcpctl delete tag ws [OPTIONS] <WORKSPACE> <KEYS>...
Command Aliases: workspace, workspaces
Arguments:
<WORKSPACE>— Workspace name or ID (ws-xxx)<KEYS>— Space-separated list of tag names to remove: flat tags and/or binding keys (e.g., env team costcenter)
Options:
-
--org <ORG>— Organization name (required when using workspace name) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl delete tag prj
Delete tags from a project
Usage: hcpctl delete tag prj [OPTIONS] <PROJECT> <KEYS>...
Command Aliases: project, projects
Arguments:
<PROJECT>— Project name or ID (prj-xxx)<KEYS>— Space-separated list of tag binding keys to remove (e.g., env team costcenter)
Options:
-
--org <ORG>— Organization name (required when using project name) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl purge
Purge resources (destructive operations with mandatory confirmation)
These operations are IRREVERSIBLE and always require interactive confirmation. The --batch flag is ignored for purge commands.
Usage: hcpctl purge <COMMAND>
Subcommands:
state— Purge all resources from a workspace's Terraform staterun— Cancel/discard pending runs blocking a workspace
hcpctl purge state
Purge all resources from a workspace's Terraform state
This is a DESTRUCTIVE operation that removes all resources from the state. The actual infrastructure will NOT be destroyed, but Terraform will "forget" about the resources, making them orphaned.
PROCEDURE:
- Fetches workspace info and validates it exists
- Fetches current state version metadata
- Displays warning and requires confirmation (type workspace ID)
- LOCKS the workspace to prevent concurrent modifications
- Downloads the current Terraform state file
- Creates a new empty state (preserving lineage, incrementing serial)
- Uploads the empty state as a new state version
- UNLOCKS the workspace (always, even on error)
SAFETY:
- Requires interactive confirmation by default (--batch is ignored)
- Requires exact workspace ID (ws-xxx), NOT workspace name
- Workspace is locked during the entire operation
- If upload fails, workspace is still unlocked
- Original state lineage is preserved for consistency
USE CASES:
- Cleaning up a workspace before deletion
- Resetting state after manual infrastructure changes
- Preparing for re-import of resources
- Removing orphaned resources from state
WARNING:
- This operation is IRREVERSIBLE without manual state recovery.
- Cloud resources will continue to exist but will no longer be tracked by Terraform.
Usage: hcpctl purge state [OPTIONS] <WORKSPACE_ID>
Arguments:
-
<WORKSPACE_ID>— Workspace ID (ws-xxx) to purge state fromMust be the exact workspace ID, not the workspace name. You can find the workspace ID using: hcpctl get ws NAME --org ORG -o json
Options:
--my-resume-is-updated— Batch mode - no interactive prompts, no spinners
hcpctl purge run
Cancel/discard pending runs blocking a workspace
Cancels or discards all pending runs that are blocking a workspace, including the current run holding the workspace lock if applicable.
PROCEDURE:
- Resolves workspace by name or ID (auto-discovers organization)
- Fetches all pending runs and current run
- Displays summary table with run details
- Requires user confirmation
- Processes runs: pending first (newest→oldest), then current run
- Uses appropriate action (cancel/discard) based on run state
ACTIONS:
- cancel: Interrupts actively executing run (planning/applying)
- discard: Skips run waiting for confirmation or priority
USE CASES:
- Clearing stacked pending runs from CI/CD
- Unblocking workspace stuck on failed/abandoned run
- Cleaning up runs before workspace maintenance
NOTES:
- Use --dry-run to preview without making changes
- Workspace name can be used (auto-discovers organization)
- Workspace ID (ws-xxx) can also be used directly
Usage: hcpctl purge run [OPTIONS] <WORKSPACE>
Command Alias: runs
Arguments:
-
<WORKSPACE>— Workspace name or ID (ws-xxx) to purge runs fromCan be either:
- Workspace name (e.g., "my-workspace") - requires --org or auto-discovery
- Workspace ID (e.g., "ws-abc123") - organization auto-detected
Options:
-o,--org <ORG>— Organization name (auto-detected if not provided)--dry-run— Preview what would be canceled without making changes
hcpctl download
Download resources (configuration files, etc.)
Usage: hcpctl download <COMMAND>
Subcommands:
config— Download workspace configuration files (tar.gz)
hcpctl download config
Download workspace configuration files (tar.gz)
Downloads the Terraform configuration files associated with a workspace's current or specified configuration version.
PROCEDURE:
- Resolves workspace by name or ID (auto-discovers organization)
- Fetches configuration version details (current or specified)
- Downloads the configuration archive (tar.gz)
- Saves to specified output file or default name
OUTPUT:
- By default, saves to: configuration-{cv_id}.tar.gz
- Use --output to specify a custom path.
EXAMPLES:
- hcpctl download config my-workspace --org my-org
- hcpctl download config ws-abc123
- hcpctl download config my-ws --output ./config.tar.gz
- hcpctl download config my-ws --cv-id cv-xyz789
Usage: hcpctl download config [OPTIONS] <WORKSPACE>
Command Alias: cfg
Arguments:
-
<WORKSPACE>— Workspace name or ID (ws-xxx) to download configuration fromCan be either:
- Workspace name (e.g., "my-workspace") - requires --org or auto-discovery
- Workspace ID (e.g., "ws-abc123") - organization auto-detected
Options:
-
-o,--org <ORG>— Organization name (auto-detected if not provided) -
--cv-id <CV_ID>— Specific configuration version ID (default: current/latest)If not specified, downloads the most recent uploaded configuration version.
-
--output <OUTPUT>— Output file path (default: configuration-{cv_id}.tar.gz)
hcpctl logs
View logs for a run (plan or apply)
Target can be: run-xxx Run ID - directly fetches logs for that run ws-xxx Workspace ID - fetches current-run logs name Workspace name - fetches current-run logs (requires --org)
Usage: hcpctl logs [OPTIONS] <TARGET>
Command Alias: log
Arguments:
-
<TARGET>— Run ID (run-xxx), workspace ID (ws-xxx), or workspace name- run-xxx directly fetches logs for that run
- ws-xxx fetches logs for workspace's current run
- name workspace name, fetches current run (requires --org)
Options:
-
-O,--org <ORG>— Organization name (required when target is a workspace name) -
-a,--apply— Show apply log instead of plan log (default: plan)Default value:
false -
-f,--follow— Follow log output in real-time until completion (like tail -f)Default value:
false -
--raw— Output raw log without parsing (default: extract @message from JSON lines)Default value:
false
hcpctl watch
Watch resources for changes
Usage: hcpctl watch <COMMAND>
Subcommands:
ws— Watch a workspace for new runs and stream their logs
hcpctl watch ws
Watch a workspace for new runs and stream their logs
Continuously monitors a workspace for new runs. When a new run starts, automatically streams its logs until completion, then watches for the next run. Logs are prefixed with [run-xxx] by default.
Usage: hcpctl watch ws [OPTIONS] <TARGET>
Command Alias: workspace
Arguments:
-
<TARGET>— Workspace ID (ws-xxx) or workspace namews-xxx Workspace ID - watches directly name Workspace name - requires --org or auto-discovery
Options:
-
-O,--org <ORG>— Organization name (optional - will search all orgs if not specified) -
-a,--apply— Show apply logs instead of plan logs (default: plan)Default value:
false -
--no-prefix— Disable [run-xxx] prefix on log output (default: prefix enabled)Default value:
false -
-i,--interval <INTERVAL>— Poll interval in seconds (default: 3)Default value:
3 -
--raw— Output raw log without parsing (default: extract @message from JSON lines)Default value:
false
hcpctl invite
Invite a user to an organization
Usage: hcpctl invite [OPTIONS] --email <EMAIL> --org <ORG>
Options:
-
--email <EMAIL>— Email address of user to invite -
--org <ORG>— Organization name to invite user to -
--teams <TEAMS>— Team ID(s) to add user to (comma-separated, e.g. team-xxx,team-yyy) -
-o,--output <OUTPUT>— Output formatDefault value:
tablePossible values:
table: ASCII table (default)csv: Comma-separated valuesjson: JSON arrayyaml: YAML format
hcpctl set
Set resource properties (assign workspace to project, etc.)
Usage: hcpctl set <COMMAND>
Subcommands:
ws— Modify workspace settings (project assignment, terraform version, etc.)tag— Set tag bindings on a workspace or project
hcpctl set ws
Modify workspace settings (project assignment, terraform version, etc.)
Usage: hcpctl set ws [OPTIONS] <--prj <PROJECT>|--terraform-version <TERRAFORM_VERSION>> <WORKSPACE>
Command Aliases: workspace, workspaces
Arguments:
<WORKSPACE>— Workspace name or ID (ws-xxx)
Options:
-
-p,--prj <PROJECT>— Target project name or ID (prj-xxx) -
--terraform-version <TERRAFORM_VERSION>[alias:tf-version] — Terraform version to set (e.g. 1.5.0) -
--org <ORG>— Organization name (auto-discovered when using workspace ID) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl set tag
Set tag bindings on a workspace or project
Usage: hcpctl set tag <COMMAND>
Command Alias: tags
Subcommands:
ws— Set tags on a workspaceprj— Set tags on a project
hcpctl set tag ws
Set tags on a workspace
Usage: hcpctl set tag ws [OPTIONS] <WORKSPACE> <TAGS>...
Command Aliases: workspace, workspaces
Arguments:
<WORKSPACE>— Workspace name or ID (ws-xxx)<TAGS>— Space-separated list of tags: flat names (e.g., env team) and/or key=value bindings (e.g., env=prod)
Options:
-
--org <ORG>— Organization name (required when using workspace name) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl set tag prj
Set tags on a project
Usage: hcpctl set tag prj [OPTIONS] <PROJECT> <TAGS>...
Command Aliases: project, projects
Arguments:
<PROJECT>— Project name or ID (prj-xxx)<TAGS>— Space-separated list of key=value tag bindings (projects only support key=value, not flat tags)
Options:
-
--org <ORG>— Organization name (required when using project name) -
-y,--yes— Skip confirmation promptDefault value:
false
hcpctl config
Manage connection contexts for multiple TFE/HCP instances
Usage: hcpctl config <COMMAND>
Subcommands:
set-context— Set a context entry in the config fileuse-context— Set the current-context in the config fileget-contexts— Describe one or many contextscurrent-context— Display the current-contextdelete-context— Delete the specified context from the config fileview— Display config file contents
hcpctl config set-context
Set a context entry in the config file
Usage: hcpctl config set-context [OPTIONS] <NAME>
EXAMPLES:
- hcpctl config set-context prod --host app.terraform.io --org my-org
- hcpctl config set-context dev --host tfe.corp.com --token
- hcpctl config set-context prod --org new-org # update existing context
Arguments:
<NAME>— Context name
Options:
--host <HOST>— TFE/HCP host URL--token <TOKEN>— API token (stored in config file)--org <ORG>— Default organization
hcpctl config use-context
Set the current-context in the config file
Usage: hcpctl config use-context <NAME>
Arguments:
<NAME>— Context name to activate
hcpctl config get-contexts
Describe one or many contexts
Usage: hcpctl config get-contexts
hcpctl config current-context
Display the current-context
Usage: hcpctl config current-context
hcpctl config delete-context
Delete the specified context from the config file
Usage: hcpctl config delete-context <NAME>
Arguments:
<NAME>— Context name to delete
hcpctl config view
Display config file contents
Usage: hcpctl config view
hcpctl update
Update hcpctl to the latest version
Usage: hcpctl update
This document was generated automatically by
clap-markdown.