.iac DSL instead of TypeScript or Python. When you reference one resource’s output inside another resource’s attributes, ubx records that as a dependency edge, builds the graph, topologically sorts the resources, and generates code that creates them in the right order. You don’t declare the order — you declare the relationships, and the order follows.
What you’ll learn
- How to reference one resource’s output attribute from another
- How ubx infers the dependency order automatically from resource output references
- When to use explicit
depends_onvs letting ubx infer it
Why this matters
The topological sort means you can declare resources in any order in your
.iac file. ubx determines the correct apply order from the dependency graph — not from file order. This makes large stacks easier to organise without worrying about declaration order.The source code
How it works
The IR pass builds a dependency graph
Every
unit.x.y.attr reference is recorded as an IRRef with Pending: true. The IR builder constructs a directed graph: the DHCP association depends on both the VPC and the DHCP options object.Topological sort determines apply order
Resources are sorted so that dependencies are always created before dependents. The VPC and DHCP options can be created in parallel; the association waits for both.
What ubx generates
Common mistakes
Run it
What you learned
ubx builds a dependency graph from resource output references and topologically sorts resources
depends_on is only needed for side-effect dependencies not expressed by direct referencesResources can be declared in any order in
.iac — apply order is computed, not declaredNext steps
Pending refs: RDS to Helm
The Pending<T> type system in depth
Pending type concept
Deep dive into Resolved vs Pending values
Full runnable example: github.com/ubiquex/ubx-examples/03-multiple-resources-with-deps

