
terraform-plugin
Terraform Cloud plugin that inspects runs, logs, and plan JSON and blocks unreviewed applies.
- version
- 1.7.13
- GitHub stars
- 60
What it does
- Adds the
terraform-opsagent, sixtfc-*skills, and avalidate-terraform-apply.shPreToolUse hook on Bash - Covers run listing, run status, run logs, and plan JSON analysis across configured TFC workspaces
- Enforces a block on
terraform applyunless it applies a saved plan file, including auto-approve variants - Designed for teams using Terraform Cloud who need run history, debugging logs, and plan review from Claude Code
Terraform and Terraform Cloud - infrastructure as code
Add marketplace
/plugin marketplace add laurigates/claude-pluginsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install terraform-plugin@laurigates-claude-pluginsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceInfrastructure Terraform
Expert knowledge for Infrastructure as Code using Terraform with focus on declarative HCL, state management, and resilient infrastructure.
When to Use This Skill
| Use this skill when... | Use a tfc-* sibling instead when... |
|---|---|
| Writing or modifying Terraform HCL configuration locally | Inspecting Terraform Cloud run state via API (tfc-run-status) |
Running terraform init/plan/apply/destroy against a backend | Reading TFC plan/apply log streams (tfc-run-logs) |
| Designing module structure, providers, or remote backends | Analyzing structured plan JSON from a TFC run (tfc-plan-json) |
| Debugging local state, drift, or import workflows | Listing or filtering TFC run history (tfc-list-runs, tfc-workspace-runs) |
Core Expertise
Terraform & IaC
- Declarative Infrastructure: Clean, modular, and reusable HCL code
- State Management: Protecting and managing Terraform state with remote backends
- Providers & Modules: Leveraging community and custom providers/modules
- Execution Lifecycle: Mastering the plan -> review -> apply workflow
Infrastructure Provisioning Process
- Plan First: Always generate
terraform planand review carefully before changes - Modularize: Break down infrastructure into reusable and composable modules
- Secure State: Use remote backends with locking to protect state file
- Parameterize: Use variables and outputs for flexible and configurable infrastructure
- Destroy with Caution: Double-check plan before running
terraform destroy
Essential Commands
# Core workflow
terraform init # Initialize working directory
terraform plan # Generate execution plan
terraform apply # Apply changes
terraform destroy # Destroy infrastructure
# State management
terraform state list # List all resources
terraform state show <resource> # Show specific resource
terraform state pull > backup.tfstate # Backup state
# Validation and formatting
terraform validate # Validate configuration
terraform fmt -recursive # Format all files recursively
terraform fmt path/to/dir # Format specific directory
terraform graph | dot -Tsvg > graph.svg # Dependency graph
# Working with directories (use -chdir to stay in repo root)
terraform -chdir=gcp fmt # Format files in gcp/ directory
terraform -chdir=gcp validate # Validate gcp/ configuration
terraform -chdir=gcp plan # Plan from specific directory
terraform -chdir=modules/vpc init # Init module directory
# Debugging
export TF_LOG=DEBUG # Enable debug logging
terraform plan -out=tfplan # Save plan for review
terraform show tfplan # View saved plan
Best Practices
Module Structure
module "vpc" {
source = "./modules/vpc"
version = "1.0.0"
vpc_cidr = var.vpc_cidr
environment = var.environment
}
output "vpc_id" {
value = module.vpc.vpc_id
}
Variable Configuration
variable "environment" {
description = "Environment name"
type = string
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Environment must be dev, staging, or prod."
}
}
Remote State Backend
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "terraform-locks"
}
}
Provider Configuration
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
required_version = ">= 1.5"
}
Key Debugging Techniques
State Debugging
# State inspection
terraform state list
terraform state show aws_instance.web
# State recovery
terraform refresh
terraform plan -refresh-only
terraform import aws_instance.existing i-1234567890
Error Resolution
# Provider errors
terraform init -upgrade
terraform init -reconfigure
# Resource conflicts
terraform taint aws_instance.broken
terraform apply -target=aws_instance.web
Agentic Optimizations
| Context | Command |
|---|---|
| Format directory | terraform -chdir=path/to/dir fmt |
| Check format (CI) | terraform fmt -check -recursive |
| Validate config | terraform -chdir=path/to/dir validate |
| Compact plan | terraform plan -compact-warnings |
| JSON plan output | terraform plan -out=plan.tfplan && terraform show -json plan.tfplan |
| List resources | terraform state list |
Quick Reference
| Flag | Description |
|---|---|
-chdir=DIR | Change to DIR before running command |
-recursive | Process directories recursively |
-check | Check formatting without changes (CI) |
-compact-warnings | Show warnings in compact form |
-json | Output in JSON format |
-out=FILE | Save plan to file |
-target=RESOURCE | Target specific resource |
-refresh-only | Only refresh state, no changes |
For detailed debugging patterns, advanced module design, CI/CD integration, and troubleshooting strategies, see REFERENCE.md.
Readme
Terraform Plugin
Terraform Cloud (TFC) automation for infrastructure management - list runs, check status, fetch logs, and analyze plan JSON output.
Overview
This plugin provides comprehensive Terraform Cloud API automation for monitoring and analyzing infrastructure runs, plans, and applies. Work with TFC workspaces, retrieve logs, analyze plan changes, and track run status directly from Claude Code.
Skills
| Skill | Description |
|---|---|
tfc-run-logs | Retrieve plan and apply logs from Terraform Cloud runs |
tfc-workspace-runs | Convenience wrapper for listing runs in configured workspaces |
tfc-list-runs | List and filter runs from Terraform Cloud workspaces |
tfc-run-status | Quick status check for TFC runs with resource changes and actions |
tfc-plan-json | Download and analyze structured Terraform plan JSON output |
Hooks
validate-terraform-apply.sh is a PreToolUse hook on the Bash tool that gates
an unreviewed apply.
| Command | Verdict |
|---|---|
terraform apply | Blocked — nothing was reviewed |
terraform apply -auto-approve, including the quoted spellings and alongside a plan file | Blocked |
terraform apply -refresh=false, terraform apply 2>&1 | tee log | Blocked — no plan file anywhere in the command |
timeout 300 terraform apply, env -i terraform apply, for d in …; do terraform apply; done | Blocked — the wrapper and the loop keyword do not hide the program |
terraform apply tfplan | Allowed — applies exactly the saved plan |
| A quoted argument, heredoc body, or comment carrying the phrase | Allowed |
bash -c "terraform apply", echo "$(terraform apply)" | Blocked — that text is shell, not data |
The hook decides command position with ast-grep --lang bash
(tree-sitter-bash), the classifier hooks-plugin/hooks/bash-antipatterns.sh
adopted in #2008. Each command node of the Bash call is examined on its own,
so a heredoc body is never a command, a redirection's fd digit is never an
argument, a do/then keyword is never glued to the program name, and any
wrapper — sudo, timeout, nice, stdbuf, xargs, uv run — is just the
front of the same node. A PR body or search query quoting terraform apply
executes nothing and is not gated (#2506). The one thing tree-sitter cannot see
into is a shell invoker's script argument, so bash -c "…", sh -c '…' and
eval "…" have their quoted arguments re-parsed as shell.
A program name assembled from an expansion — A='terraform apply -auto-approve'; $A — carries no terraform token and is not caught. Neither
the pre-#2506 regex nor any later version caught it; the gate stops the
unreviewed apply written by habit, not one written to evade it.
Where ast-grep is not installed the hook does not fire at all. It fails
open, exactly as bash-antipatterns.sh does, because a PreToolUse hook that
hard-fails without its parser breaks every Bash call. Install ast-grep (brew install ast-grep, cargo install ast-grep) for the gate to be in effect.
Quotes are removed rather than masked, because the shell removes them: terraform apply "-auto-approve" really delivers -auto-approve to the process, and is
blocked. A plan file is a positional operand carrying no =, not consumed as a
preceding bare flag's value (so -var foo=bar and -target aws_x.y do not
count as one), and named literally — a $VAR, $(…) or backtick operand
cannot be resolved here, could expand to -auto-approve, and is treated as an
unreviewed apply.
Prerequisites
All skills require a Terraform Cloud API token:
export TFE_TOKEN="your-api-token" # User or team token (not organization token)
export TFE_ADDRESS="app.terraform.io" # Optional, defaults to app.terraform.io
Common Use Cases
Check Workspace Runs
List recent runs for a workspace:
# Using tfc-workspace-runs skill
# Supports: github, sentry, gcp, onelogin, twingate
Get Run Logs
Retrieve plan and apply logs for debugging:
# Using tfc-run-logs skill
# Fetches both plan and apply logs for a run ID
Analyze Plan Changes
Download and analyze structured plan JSON:
# Using tfc-plan-json skill
# Get detailed resource change information
Monitor Run Status
Quick status check with resource counts:
# Using tfc-run-status skill
# Shows status, resource changes, and available actions
Filter Runs
List runs by status, operation type, or date:
# Using tfc-list-runs skill
# Filter by: status, status group, operation, source, timeframe
Installation
/plugin install terraform-plugin@laurigates-claude-plugins
License
MIT
Details
- Marketplace
- laurigates/claude-plugins
- Source
- terraform-plugin
- Author
- Lauri Gates
- Category
- Infrastructure
- License
- MIT
- Keywords
- terraform, infrastructure, iac, tfc
- Listed since
- Apr 7, 2026
More from laurigates/claude-plugins
All 52- testing-pluginv3.27.2
- tools-pluginv2.16.2
- typescript-pluginv1.10.4
- video-pluginv2.0.2
- workflow-orchestration-pluginv1.20.0
- youtube-pluginv1.1.0
- accessibility-pluginv2.3.6
- agent-patterns-pluginv2.58.5
- agents-pluginv1.16.3
- api-pluginv2.0.1
- bevy-pluginv1.4.2
- bios-pluginv1.2.0
- blog-pluginv1.3.4
- blueprint-pluginv3.52.0
- cloud-pluginv1.1.1
- code-quality-pluginv1.30.4
- codebase-attributes-pluginv1.3.4
- comfyui-pluginv1.15.7
- communication-pluginv1.2.7
- component-patterns-pluginv1.5.4
- configure-pluginv1.43.12
- container-pluginv2.11.5
- css-pluginv1.2.4
- documentation-pluginv1.16.1
Similar to terraform-plugin
More DevOps & Cloud
terraformTheBushidoCollective/han201 starsTerraform configuration validation and infrastructure-as-code best practices
terraform-toolkitarmanzeroeight/fastagent-plugins29 starsTerraform infrastructure as code toolkit with module scaffolding, state management, cost estimation, and upgrade assistance. Includes strategic IaC architect ag
iac-terraformahmedasmar/devops-claude-skills206 starsInfrastructure as Code with Terraform and Terragrunt. Use this skill whenever the user mentions Terraform, Terragrunt, HCL, or infrastructure as code. Triggers
terraform-helperrohitg00/awesome-claude-code-toolkit2.8K starsTerraform module creation and infrastructure planning
cloudformation-toolkitarmanzeroeight/fastagent-plugins29 starsCloudFormation infrastructure as code toolkit for stack design, template validation, and deployment strategies. Includes cfn architect agent for strategic Cloud
cloud-infrastructurewshobson/agents42.8K starsCloud architecture design for AWS/Azure/GCP/OCI, Kubernetes cluster configuration, Terraform infrastructure-as-code, hybrid cloud networking, and multi-cloud co