AgentsTerraform / OpenTofu

Terraform / OpenTofu AI Agent Directives

Plan security, state drift, module upgrades, OPA policy and cost estimates.

7 directivesDifficulty: beginner → advanced

Terraform and OpenTofu are the language most teams use to describe infrastructure, which makes the code, the plan, and the state the perfect targets for an AI agent. These directives turn an agent into a reviewer that sits between the plan and the apply: scanning a terraform plan for security risks, detecting state drift against live infrastructure, planning module and provider upgrades with breaking-change analysis, validating plans against OPA policy, estimating cost, catching refactor mistakes that would destroy resources, and staging imports for brownfield estates. Each windsurf terraform or cursor rules terraform directive is written to run against the real CLI, from opentofu plan and terraform show to opa eval, and it always keeps the agent read-only unless a change is explicitly authorized. The central idea is that terraform drift and plan risks are reproducible analyses an agent can do reliably rather than mysteries to be feared. Teams collecting cursor rules terraform or opentofu directives get prompts that produce a diff table, a severity list, and a safe migration order instead of a vague summary. Save these for any branch that changes terraform, and the review writes itself against the plan. Put them in a rules file and re-run whenever a PR touches IaC, and the most fragile part of infrastructure change becomes the part an agent checks first and consistently.

intermediate10 minsecurity

Terraform Plan Security Review

Analyze a Terraform plan output for security risks: public S3 buckets, open security groups, plaintext secrets, and overly permissive IAM.

windsurfcursorclaude-codecopilotcline
View directive
intermediate10 mindrift

Terraform State Drift Detection

Compare Terraform state with real infrastructure to detect drift and unauthorized out-of-band changes.

opencodecursorwindsurfclaude-codecopilot
View directive
advanced20 minmodules

Terraform Module Upgrade Assistant

Upgrade Terraform modules to the latest provider versions with breaking change analysis and migration steps.

copilotcursorwindsurfclaude-code
View directive
advanced15 minopa

Terraform Policy Check with OPA

Validate Terraform plans against Open Policy Agent rules for tagging, naming, and security compliance.

clinecursorwindsurfclaude-code
View directive
intermediate10 mincost

Terraform Cost Estimation

Estimate the monthly cost impact of a Terraform plan by analyzing resource changes and pricing data.

cursorwindsurfclaude-codecopilot
View directive
advanced15 minrefactor

Terraform Refactor Detector

Detect when Terraform changes will cause resource recreation instead of in-place update, and suggest moved blocks.

claude-codecursorwindsurf
View directive
intermediate10 minimport

Terraform Import Planner

Generate terraform import commands for existing cloud resources that are not yet managed by Terraform.

windsurfcursorclaude-codecline
View directive
THE NEXT STEP

Stop pasting. Start automating.

Every one of these Terraform / OpenTofu directives is something Devopsify can run continuously against your estate, with policy gates, approvals, and a retained audit trail instead of a manual run.