Dependencies, Cross-Stack References, and Phases
Real infrastructure graphs are not flat. Netherframe has several features to deal with dependencies at different levels.
Stack Dependencies
Use stack.depends_on(...) when one stack must be ordered after another.
This is the highest-level dependency mechanism and usually the easiest one to understand operationally.
Dependency Levels Diagram
flowchart TD
A[Stack dependency] --> B[Ordering between stacks]
B --> C[Cross-stack reference]
C --> D[Value-level dependency]
D --> E{Cycle detected?}
E -->|No| F[Single-pass deployment]
E -->|Yes| G[Phase planning]
Cross-Stack References
Sometimes a resource in one stack needs a value from another stack. Netherframe can preserve and synthesize these references so stacks still compose cleanly.
Typical examples:
- a service stack needing a VPC ID from a network stack
- an application stack needing a bucket name from a shared storage stack
Circular Dependencies
Some graphs cannot be applied in a single pass because resources depend on values that only exist after another resource is created.
Netherframe addresses this with phased execution planning.
What A Phase Plan Does
A phase plan:
- analyzes the dependency graph
- identifies cycles
- groups resources into one or more ordered phases
- emits phased artifacts so deployment can proceed safely
Phase Planning Flow
flowchart LR
A[Infrastructure graph] --> B[Dependency analysis]
B --> C[Cycle detection]
C --> D[Phase plan]
D --> E[Phase 1 output]
D --> F[Phase 2 output]
D --> G[Later phases if needed]
When To Think About Phases
You usually do not need to design for phases first. Most teams should:
- model the infrastructure naturally
- let Netherframe detect whether phasing is required
- inspect phased output only when the graph becomes complex