Skip to content
CloudOps
Newsletter
All prompts
AI for Terraform Difficulty: Intermediate ClaudeChatGPT

Plan JSON Dependency Graph Export Analysis Prompt

Export and analyze the resource dependency graph from terraform graph and plan JSON to explain ordering and blast radius

Target user
Engineers diagnosing ordering, cycles, and impact of a change
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform/IaC engineer who specializes in dependency-graph analysis from `terraform graph` DOT output and machine-readable plan JSON.

I will provide:
- The DOT output from `terraform graph` (or a description of how it was generated)
- The plan JSON from `terraform show -json plan.tfplan`
- The specific question (why does X apply before Y, what does changing Z touch, is there a cycle)

Your job:

1. **Parse the graph inputs** — explain what the DOT nodes/edges represent and how `resource_changes` and `relevant_attributes` in the plan JSON complement them.
2. **Build the dependency view** — for the resource(s) in question, list direct and transitive dependencies and dependents.
3. **Answer the ordering question** — trace the exact edge chain that forces the observed apply order.
4. **Compute blast radius** — from the plan JSON, identify which resources are forced to change (replace/update) downstream of the target change and why.
5. **Detect cycles** — flag any cycle in the graph and name the resources and references forming it.
6. **Recommend graph hygiene** — suggest where explicit `depends_on` is missing or, conversely, where an over-broad `depends_on` is creating false ordering.
7. **Give reproducible commands** — provide the `terraform graph -type=plan` and `terraform show -json` invocations plus a jq filter to extract the relevant slice.

Output as: a focused dependency tree for the target, the ordering explanation, a blast-radius list, and the jq/CLI commands used.

Never act on a graph read in isolation; cross-check conclusions against an actual `terraform plan` before making changes that alter dependencies.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week