For full CLI reference documentation, visit our official guide at https://docs.terrakube.io/user-guide/terrakube-cli.
- Download & Installation
- Adding Terrakube CLI to PATH
- Building & Testing from Source
- Quick Start Guide
- Contributing
- Security
You can download pre-compiled binaries directly from our GitHub Releases page, or install via Snap on Linux/Ubuntu.
You can install the local .snap package:
sudo snap install --dangerous terrakube-cli_*.snapBoth terrakube and terrakube-cli commands will be available:
terrakube --version
terrakube-cli --helpDownload the binary using curl or wget:
# Example: Download latest Linux amd64 binary
curl -sSL -o terrakube https://github.com/terrakube-io/terrakube-cli/releases/latest/download/terrakube-linux-amd64
chmod +x terrakubeDownload the binary using PowerShell:
# Download latest Windows amd64 binary
Invoke-WebRequest -Uri "https://github.com/terrakube-io/terrakube-cli/releases/latest/download/terrakube-windows-amd64.exe" -OutFile "terrakube.exe"To run terrakube from any directory, add the binary location to your system's PATH environment variable.
Move the compiled or downloaded binary to /usr/local/bin:
sudo mv terrakube /usr/local/bin/
terrakube --versionIf you prefer placing the binary in a custom folder (e.g., ~/.local/bin or ~/bin):
mkdir -p ~/.local/bin
mv terrakube ~/.local/bin/Add the following line to your shell configuration file (~/.bashrc or ~/.zshrc):
export PATH="$HOME/.local/bin:$PATH"Reload shell settings:
source ~/.bashrc # Or source ~/.zshrcTo permanently append the folder containing terrakube.exe to your user PATH:
# Assuming terrakube.exe is placed in C:\Tools\terrakube
$targetDir = "C:\Tools\terrakube"
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$targetDir", "User")Restart PowerShell and verify:
terrakube --version- Move
terrakube.exeto a permanent folder (e.g.,C:\Tools\terrakube). - Press
Win + R, typesysdm.cpl, and press Enter. - Open the Advanced tab and click Environment Variables.
- Under User variables, select Path and click Edit.
- Click New and add the folder path (e.g.,
C:\Tools\terrakube). - Click OK to save and restart your command prompt or terminal.
- Go 1.22 or higher
Clone the repository and compile using go build:
git clone https://github.com/terrakube-io/terrakube-cli.git
cd terrakube-cli
go build -o terrakube main.goVerify compilation:
./terrakube --helpTo build the Snap package on Ubuntu/Linux:
-
Install
snapcraft:sudo snap install snapcraft --classic
-
Build the snap:
# Build directly in container (LXD/Multipass): snapcraft # Or build locally in destructive mode: snapcraft --destructive-mode
-
Install the locally generated
.snappackage:sudo snap install --dangerous terrakube-cli_*.snap
Run unit tests across all Golang packages:
go test ./...Terrakube CLI includes comprehensive end-to-end integration tests written using BATS.
Important
To execute the E2E test suite, you must have a running Terrakube Server test instance.
Set the API endpoint URL (e.g., https://terrakube-api.platform.local) and an Admin Personal Access Token (PAT) in your environment variables:
export TERRAKUBE_API_URL="https://terrakube-api.platform.local"
export TERRAKUBE_PAT="XXXXXXXXXXXXX" # Replace with a valid Terrakube Admin Personal Access TokenExecute the E2E operations test suite:
bats tests/e2e_operations.batsThis step-by-step example demonstrates standard Terrakube CLI operations based on end-to-end workflows.
Authenticate against your Terrakube server using your API URL and Personal Access Token (PAT):
terrakube login -a "https://terrakube-api.platform.local" -t "XXXXXXXXXXXXX"Create a new organization configured for remote execution:
terrakube organization create \
--name "demo-org" \
--description "Production Engineering Organization" \
--execution-mode "remote" \
--output jsonSave the returned organization ID (e.g., 09e86337-b6bb-49e0-82aa-c114ad0f41ab) for subsequent operations.
Create a TERRAKUBE_ADMIN team inside your organization with admin permissions:
terrakube team create \
-o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \
--name "TERRAKUBE_ADMIN" \
--role "Admin" \
--manage-workspace \
--manage-module \
--manage-provider \
--manage-state \
--manage-collection \
--manage-vcs \
--manage-template \
--manage-job \
--plan-job \
--approve-job \
--output tableCreate a new workspace using OpenTofu (tofu) linked to the repository terrakube-docker-compose:
terrakube workspace create \
-o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \
--name "docker-compose-infra" \
--description "Docker Compose OpenTofu Workspace" \
--source "https://github.com/terrakube-io/terrakube-docker-compose" \
--branch "main" \
--folder "/" \
--iac-type "tofu" \
--iac-version "1.12.5" \
--execution-mode "remote" \
--output jsonCreate environment variables for the workspace:
terrakube variable create \
-o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \
-w "<WORKSPACE_ID>" \
--key "ENVIRONMENT" \
--value "production" \
--category "ENV" \
--output table-
Create an organization-level tag:
terrakube tag create \ -o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \ --name "production" \ --output json
-
Associate the tag with your workspace:
terrakube workspace-tag create \ -o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \ -w "<WORKSPACE_ID>" \ --tag-id "<TAG_ID>" \ --output table
-
Create an organization or workspace notification configuration:
terrakube notification-configuration create \ -o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \ --name "slack-alerts" \ --channel-type "SLACK" \ --destination-url "https://hooks.slack.com/services/T00/B00/X00" \ --message-style "DETAILED" \ --active \ --output json
-
Add a trigger on job completion or failure:
terrakube notification-trigger create \ -o "09e86337-b6bb-49e0-82aa-c114ad0f41ab" \ --notification-configuration "<NOTIFICATION_CONFIGURATION_ID>" \ --job-status "completed" \ --output table
We welcome contributions from the community! Please check out our Contributing Guidelines for information on setting up your environment, code formatting conventions, submitting pull requests, and registering new CLI commands.
Security vulnerabilities or concerns should be reported responsibly. Please read our Security Policy for details on supported versions and reporting procedures.