Skip to main content
Glama

terraform_state_show

View detailed information about a specific Terraform resource in your state file to inspect current configurations and attributes.

Instructions

Show details of a specific resource in Terraform state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing Terraform files
resourceYesResource address (e.g., 'aws_instance.web')

Implementation Reference

  • The implementation of the terraform_state_show handler, which executes 'terraform state show' in the specified directory.
    export async function terraformStateShow(args: Record<string, unknown>): Promise<string> {
      const directory = args.directory as string;
      const resource = args.resource as string;
      if (!directory) throw new Error("Terraform directory is required");
      if (!resource) throw new Error("Resource address is required");
    
      try {
        const { stdout } = await execFileAsync("terraform", ["state", "show", resource], {
          cwd: directory,
          timeout: 30000,
        });
        return `Terraform resource: ${resource}\n\n${stdout}`;
      } catch (error: any) {
        throw new Error(`Terraform state show failed: ${error.stderr || error.message}`);
      }
    }
  • The schema definition for the terraform_state_show tool.
      name: "terraform_state_show",
      description: "Show details of a specific resource in Terraform state",
      inputSchema: {
        type: "object" as const,
        properties: {
          directory: { type: "string", description: "Directory containing Terraform files" },
          resource: { type: "string", description: "Resource address (e.g., 'aws_instance.web')" },
        },
        required: ["directory", "resource"],
      },
    },
  • The tool handler dispatcher that routes 'terraform_state_show' calls to the implementation function.
    case "terraform_state_show": return terraformStateShow(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