Skip to main content
Glama

terraform_state_list

List all resources in Terraform state to manage infrastructure configurations and track deployed components.

Instructions

List all resources in the Terraform state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing Terraform files

Implementation Reference

  • The handler function that executes 'terraform state list' in the specified directory.
    export async function terraformStateList(args: Record<string, unknown>): Promise<string> {
      const directory = args.directory as string;
      if (!directory) throw new Error("Terraform directory is required");
    
      try {
        const { stdout } = await execFileAsync("terraform", ["state", "list"], {
          cwd: directory,
          timeout: 30000,
        });
        const resources = stdout.trim().split("\n").filter(Boolean);
        if (resources.length === 0) return "No resources in Terraform state.";
        return `Terraform state resources (${resources.length}):\n\n${resources.join("\n")}`;
      } catch (error: any) {
        throw new Error(`Terraform state list failed: ${error.stderr || error.message}`);
      }
    }
  • The input schema definition for the terraform_state_list tool.
    {
      name: "terraform_state_list",
      description: "List all resources in the Terraform state",
      inputSchema: {
        type: "object" as const,
        properties: {
          directory: { type: "string", description: "Directory containing Terraform files" },
        },
        required: ["directory"],
      },
    },
  • Registration logic mapping the tool name to its handler function within the tool router.
    case "terraform_state_list": return terraformStateList(a);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/batu-sonmez/infraclaude'

If you have feedback or need assistance with the MCP directory API, please join our Discord server