For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting Started

The Terrakube CLI (terrakube) is the command-line interface for managing Terrakube Server resources. This guide walks you through authenticating, configuring environment defaults, and running an end-to-end management script.


1. Authentication (login & logout)

To interact with a Terrakube instance, you must authenticate using your Terrakube Server API URL and a Personal Access Token (PAT).

Login

Authenticate and persist your credentials locally:

terrakube login --api-url "https://terrakube-api.example.com" --token "YOUR_PERSONAL_ACCESS_TOKEN"

Short flags can also be used:

terrakube login -a "https://terrakube-api.example.com" -t "YOUR_PERSONAL_ACCESS_TOKEN"

This command validates your credentials and writes configuration settings to ~/.terrakube-cli.yaml.

Logout

To clear saved credentials from your machine:

terrakube logout

2. Configuration & Environment Variables

terrakube resolves parameters using the following order of precedence:

  1. Command-line flags (e.g. --organization, --output)

  2. Environment variables

  3. Configuration file (~/.terrakube-cli.yaml)

Environment Variables

Variable
Description

TERRAKUBE_API_URL

Base API URL of your Terrakube instance (e.g., http://localhost:8080)

TERRAKUBE_TOKEN

Bearer token / Personal Access Token

TERRAKUBE_ORGANIZATION

Default Organization ID or Name

TERRAKUBE_CONFIG

Custom path to config file

Example environment configuration:


3. Global Command Options

All terrakube subcommands support the following global options:

  • --output, -o: Sets output format (json, table, yaml, tsv, none). Default: json.

  • --hide-nulls: Hides null fields in JSON/YAML output (boolean). Default: true.

  • --organization, -o: Default organization ID or name for org-scoped resources.

  • --config: Path to configuration file. Default: ~/.terrakube-cli.yaml.


4. End-to-End Quickstart Script

Below is a complete Bash script demonstrating how to log in, create an organization, set up an admin team, launch a workspace with OpenTofu, configure workspace environment variables, create a project, and assign the workspace to the project.

Last updated

Was this helpful?