productivity
Terraform Cloud CLI for AI Agents
Use the Terraform Cloud CLI from KosmoKrator to call Terraform Cloud tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Terraform Cloud CLI Setup
Terraform Cloud can be configured headlessly with `kosmokrator integrations:configure terraform`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure terraform --set api_token="$TERRAFORM_API_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor terraform --json
kosmokrator integrations:status --json Credentials
Authentication type: API token api_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_token | TERRAFORM_API_TOKEN | Secret secret | yes | API Token |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call terraform.terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json kosmo integrations:terraform terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs terraform --json
kosmo integrations:docs terraform.terraform_list_workspaces --json
kosmo integrations:schema terraform.terraform_list_workspaces --json
kosmo integrations:search "Terraform Cloud" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
terraform.terraform_list_workspaces
List workspaces in a Terraform Cloud organization. Returns workspace IDs, names, Terraform versions, and locked status.
read - Parameters
- organization, pageNumber, pageSize
kosmo integrations:call terraform.terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json kosmo integrations:terraform terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json terraform.terraform_get_workspace
Get details of a specific Terraform Cloud workspace by its ID. Returns workspace configuration, status, and VCS settings.
read - Parameters
- workspaceId
kosmo integrations:call terraform.terraform_get_workspace '{"workspaceId":"example_workspaceId"}' --json kosmo integrations:terraform terraform_get_workspace '{"workspaceId":"example_workspaceId"}' --json terraform.terraform_list_runs
List runs for a Terraform Cloud workspace. Returns run IDs, statuses, trigger reasons, and timestamps.
read - Parameters
- workspaceId, pageNumber, pageSize
kosmo integrations:call terraform.terraform_list_runs '{"workspaceId":"example_workspaceId","pageNumber":1,"pageSize":1}' --json kosmo integrations:terraform terraform_list_runs '{"workspaceId":"example_workspaceId","pageNumber":1,"pageSize":1}' --json terraform.terraform_get_run
Get details of a specific Terraform Cloud run by its ID. Returns run status, plan/apply results, and configuration version info.
read - Parameters
- runId
kosmo integrations:call terraform.terraform_get_run '{"runId":"example_runId"}' --json kosmo integrations:terraform terraform_get_run '{"runId":"example_runId"}' --json terraform.terraform_list_variables
List variables for a Terraform Cloud workspace. Returns variable names, types (Terraform or environment), and sensitivity flags.
read - Parameters
- workspaceId
kosmo integrations:call terraform.terraform_list_variables '{"workspaceId":"example_workspaceId"}' --json kosmo integrations:terraform terraform_list_variables '{"workspaceId":"example_workspaceId"}' --json terraform.terraform_list_organizations
List Terraform Cloud organizations the authenticated user has access to. Returns organization names and IDs.
read - Parameters
- pageNumber, pageSize
kosmo integrations:call terraform.terraform_list_organizations '{"pageNumber":1,"pageSize":1}' --json kosmo integrations:terraform terraform_list_organizations '{"pageNumber":1,"pageSize":1}' --json terraform.terraform_get_current_user
Get the currently authenticated Terraform Cloud user. Useful for verifying authentication and retrieving user details.
read - Parameters
- none
kosmo integrations:call terraform.terraform_get_current_user '{}' --json kosmo integrations:terraform terraform_get_current_user '{}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
terraform.terraform_list_workspaces 3 parameters
kosmo integrations:schema terraform.terraform_list_workspaces --json | Parameter | Type | Required | Description |
|---|---|---|---|
organization | string | no | The organization name to list workspaces for. |
pageNumber | integer | no | Page number for pagination (default: 1). |
pageSize | integer | no | Number of results per page, max 100 (default: 20). |
terraform.terraform_get_workspace 1 parameters
kosmo integrations:schema terraform.terraform_get_workspace --json | Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | no | The workspace ID (starts with "ws-"). |
terraform.terraform_list_runs 3 parameters
kosmo integrations:schema terraform.terraform_list_runs --json | Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | no | The workspace ID to list runs for (starts with "ws-"). |
pageNumber | integer | no | Page number for pagination (default: 1). |
pageSize | integer | no | Number of results per page, max 100 (default: 20). |
terraform.terraform_get_run 1 parameters
kosmo integrations:schema terraform.terraform_get_run --json | Parameter | Type | Required | Description |
|---|---|---|---|
runId | string | no | The run ID (starts with "run-"). |
terraform.terraform_list_variables 1 parameters
kosmo integrations:schema terraform.terraform_list_variables --json | Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | no | The workspace ID to list variables for (starts with "ws-"). |
terraform.terraform_list_organizations 2 parameters
kosmo integrations:schema terraform.terraform_list_organizations --json | Parameter | Type | Required | Description |
|---|---|---|---|
pageNumber | integer | no | Page number for pagination (default: 1). |
pageSize | integer | no | Number of results per page, max 50 (default: 20). |
terraform.terraform_get_current_user 0 parameters
kosmo integrations:schema terraform.terraform_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.