Skip to main content

Terraform

Runs Terraform commands against a working directory via the terraform CLI. An agent can initialize, validate, plan, apply, and destroy infrastructure, read output values, and inspect/manage state.

Add to an agent node's tools array with _node_type: "tool-terraform". See Connector Reference — How connectors are used.

Authentication

FieldRequiredDescription
working_dirNoPath to the directory containing .tf files; all terraform commands run with this as their working directory (cmd.Dir). If omitted, commands run in the worker process's current directory.
{
"name": "terraform",
"_node_type": "tool-terraform",
"working_dir": "/workspace/infra/prod"
}

Tools

terraform_init

Initialize Terraform working directory. Run this first before plan/apply.

Parameters

ParameterTypeRequiredDescription
upgradebooleanNoUpgrade modules and providers

Returns: The combined stdout+stderr of terraform init -no-color [-upgrade]. If the command exits non-zero, returns terraform error: <err>\n<output> instead of failing the tool call.

terraform_validate

Validate Terraform configuration syntax and internal consistency.

No parameters.

Returns: The combined stdout+stderr of terraform validate -no-color (or terraform error: <err>\n<output> on failure).

terraform_plan

Generate Terraform execution plan showing what changes will be made. No changes are applied.

Parameters

ParameterTypeRequiredDescription
varsstringNoVariables as key=value pairs comma-separated
targetstringNoTarget specific resource e.g. aws_instance.web

Returns: The combined stdout+stderr of terraform plan -no-color [-var k=v ...] [-target=<target>] (or terraform error: <err>\n<output> on failure).

terraform_apply

Apply Terraform changes to create/update infrastructure. Use auto_approve=true to skip confirmation.

Parameters

ParameterTypeRequiredDescription
varsstringNoVariables as key=value pairs comma-separated
auto_approvebooleanNoSkip interactive confirmation

Returns: The combined stdout+stderr of terraform apply -no-color [-auto-approve] [-var k=v ...] (or terraform error: <err>\n<output> on failure).

terraform_destroy

Destroy Terraform-managed infrastructure. Irreversible — use auto_approve carefully.

Parameters

ParameterTypeRequiredDescription
targetstringNoDestroy specific resource only
auto_approvebooleanNoSkip interactive confirmation

Returns: The combined stdout+stderr of terraform destroy -no-color [-auto-approve] [-target=<target>] (or terraform error: <err>\n<output> on failure).

terraform_output

Read Terraform output values (e.g. created resource IDs, URLs, IPs).

Parameters

ParameterTypeRequiredDescription
namestringNoSpecific output name (empty = all)

Returns: The combined stdout+stderr of terraform output -no-color [<name>] (or terraform error: <err>\n<output> on failure).

terraform_state

Manage Terraform state: list resources, show details, move or remove entries.

Parameters

ParameterTypeRequiredDescription
sub_commandstringYesState subcommand: list show mv rm
addressstringNoResource address e.g. aws_instance.web

Returns: The combined stdout+stderr of terraform state <sub_command> -no-color [<address>] (or terraform error: <err>\n<output> on failure).

Next