Dependency Graph

Visualize the dependency graph of your infrastructure. Oxid outputs DOT format compatible with Graphviz and other graph visualization tools.

Usage

oxid graph [flags]

The graph command analyzes the dependencies between all resources in your configuration and outputs the graph in DOT format. This can be piped to Graphviz or any tool that accepts DOT input.

Basic Usage

$ oxid graph

digraph {
  "aws_vpc.main" -> "aws_subnet.public[0]"
  "aws_vpc.main" -> "aws_subnet.public[1]"
  "aws_vpc.main" -> "aws_subnet.private[0]"
  "aws_vpc.main" -> "aws_subnet.private[1]"
  "aws_vpc.main" -> "aws_internet_gateway.main"
  "aws_vpc.main" -> "aws_security_group.web"
  "aws_vpc.main" -> "aws_security_group.api"
  "aws_subnet.public[0]" -> "aws_route_table_association.public[0]"
  "aws_subnet.public[1]" -> "aws_route_table_association.public[1]"
  "aws_subnet.private[0]" -> "aws_instance.api[0]"
  "aws_subnet.private[1]" -> "aws_instance.api[1]"
  "aws_security_group.api" -> "aws_instance.api[0]"
  "aws_security_group.api" -> "aws_instance.api[1]"
}

Rendering as an Image

Pipe the output to Graphviz to generate a visual graph:

# PNG
oxid graph | dot -Tpng -o graph.png

# SVG (scalable, better for large graphs)
oxid graph | dot -Tsvg -o graph.svg

# PDF
oxid graph | dot -Tpdf -o graph.pdf
NoteInstall Graphviz with your package manager: brew install graphviz (macOS), apt install graphviz (Ubuntu), or choco install graphviz (Windows).

Graph Types

Resource graph (default)

Shows individual resources and their dependencies. Each resource is a node, and each dependency is a directed edge.

oxid graph

Type-level graph

Collapses individual resources into their types for a higher-level view of your architecture:

oxid graph --type
digraph {
  "aws_vpc" -> "aws_subnet"
  "aws_vpc" -> "aws_internet_gateway"
  "aws_vpc" -> "aws_security_group"
  "aws_subnet" -> "aws_route_table_association"
  "aws_subnet" -> "aws_instance"
  "aws_security_group" -> "aws_instance"
}

Flags

FlagDescriptionDefault
--typeOutput a type-level graph instead of individual resources.false

Online Visualization

If you do not want to install Graphviz, paste the DOT output into an online viewer:

# Copy to clipboard (macOS)
oxid graph | pbcopy

Understanding the Graph

The graph represents the order in which Oxid will create resources during apply. An edge from A to B means "A must exist before B can be created." During destroy, this order is reversed.

Dependencies come from two sources:

  • Implicit - References in expressions (e.g., aws_vpc.main.id)
  • Explicit - The depends_on meta-argument