KosmoKrator

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.

7 functions 7 read 0 write API token auth

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 use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_token TERRAFORM_API_TOKEN Secret secret yes API Token

Call Terraform Cloud Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call terraform.terraform_list_workspaces '{
  "organization": "example_organization",
  "pageNumber": 1,
  "pageSize": 1
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:terraform terraform_list_workspaces '{
  "organization": "example_organization",
  "pageNumber": 1,
  "pageSize": 1
}' --json

Agent Discovery Commands

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

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Terraform Cloud.

terraform.terraform_list_workspaces

Read read

List workspaces in a Terraform Cloud organization. Returns workspace IDs, names, Terraform versions, and locked status.

Parameters
organization, pageNumber, pageSize

Generic CLI call

kosmo integrations:call terraform.terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json

Provider shortcut

kosmo integrations:terraform terraform_list_workspaces '{"organization":"example_organization","pageNumber":1,"pageSize":1}' --json

terraform.terraform_get_workspace

Read read

Get details of a specific Terraform Cloud workspace by its ID. Returns workspace configuration, status, and VCS settings.

Parameters
workspaceId

Generic CLI call

kosmo integrations:call terraform.terraform_get_workspace '{"workspaceId":"example_workspaceId"}' --json

Provider shortcut

kosmo integrations:terraform terraform_get_workspace '{"workspaceId":"example_workspaceId"}' --json

terraform.terraform_list_runs

Read read

List runs for a Terraform Cloud workspace. Returns run IDs, statuses, trigger reasons, and timestamps.

Parameters
workspaceId, pageNumber, pageSize

Generic CLI call

kosmo integrations:call terraform.terraform_list_runs '{"workspaceId":"example_workspaceId","pageNumber":1,"pageSize":1}' --json

Provider shortcut

kosmo integrations:terraform terraform_list_runs '{"workspaceId":"example_workspaceId","pageNumber":1,"pageSize":1}' --json

terraform.terraform_get_run

Read read

Get details of a specific Terraform Cloud run by its ID. Returns run status, plan/apply results, and configuration version info.

Parameters
runId

Generic CLI call

kosmo integrations:call terraform.terraform_get_run '{"runId":"example_runId"}' --json

Provider shortcut

kosmo integrations:terraform terraform_get_run '{"runId":"example_runId"}' --json

terraform.terraform_list_variables

Read read

List variables for a Terraform Cloud workspace. Returns variable names, types (Terraform or environment), and sensitivity flags.

Parameters
workspaceId

Generic CLI call

kosmo integrations:call terraform.terraform_list_variables '{"workspaceId":"example_workspaceId"}' --json

Provider shortcut

kosmo integrations:terraform terraform_list_variables '{"workspaceId":"example_workspaceId"}' --json

terraform.terraform_list_organizations

Read read

List Terraform Cloud organizations the authenticated user has access to. Returns organization names and IDs.

Parameters
pageNumber, pageSize

Generic CLI call

kosmo integrations:call terraform.terraform_list_organizations '{"pageNumber":1,"pageSize":1}' --json

Provider shortcut

kosmo integrations:terraform terraform_list_organizations '{"pageNumber":1,"pageSize":1}' --json

terraform.terraform_get_current_user

Read read

Get the currently authenticated Terraform Cloud user. Useful for verifying authentication and retrieving user details.

Parameters
none

Generic CLI call

kosmo integrations:call terraform.terraform_get_current_user '{}' --json

Provider shortcut

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

List workspaces in a Terraform Cloud organization. Returns workspace IDs, names, Terraform versions, and locked status.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_list_workspaces --json
ParameterTypeRequiredDescription
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

Get details of a specific Terraform Cloud workspace by its ID. Returns workspace configuration, status, and VCS settings.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_get_workspace --json
ParameterTypeRequiredDescription
workspaceId string no The workspace ID (starts with "ws-").

terraform.terraform_list_runs

List runs for a Terraform Cloud workspace. Returns run IDs, statuses, trigger reasons, and timestamps.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_list_runs --json
ParameterTypeRequiredDescription
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

Get details of a specific Terraform Cloud run by its ID. Returns run status, plan/apply results, and configuration version info.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_get_run --json
ParameterTypeRequiredDescription
runId string no The run ID (starts with "run-").

terraform.terraform_list_variables

List variables for a Terraform Cloud workspace. Returns variable names, types (Terraform or environment), and sensitivity flags.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_list_variables --json
ParameterTypeRequiredDescription
workspaceId string no The workspace ID to list variables for (starts with "ws-").

terraform.terraform_list_organizations

List Terraform Cloud organizations the authenticated user has access to. Returns organization names and IDs.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_list_organizations --json
ParameterTypeRequiredDescription
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

Get the currently authenticated Terraform Cloud user. Useful for verifying authentication and retrieving user details.

Operation
Read read
Schema command
kosmo integrations:schema terraform.terraform_get_current_user --json
ParameterTypeRequiredDescription
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.