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
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | Directory containing Terraform files | |
| resource | Yes | Resource address (e.g., 'aws_instance.web') |
Implementation Reference
- src/tools/terraform/state.ts:23-38 (handler)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}`); } } - src/tools/terraform/index.ts:31-41 (schema)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"], }, }, - src/tools/terraform/index.ts:76-76 (registration)The tool handler dispatcher that routes 'terraform_state_show' calls to the implementation function.
case "terraform_state_show": return terraformStateShow(a);