mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
61baceb308
Our reference transformer analyses and our destroy transformer analyses are built around static (not-yet-expanded) addresses so that they can correctly handle mixtures of expanded and not-yet-expanded objects in the same graph. However, this characteristic also makes them unnecessarily conservative in their handling of references between resources within different instances of the same module: we know they can never interact with each other in practice because the dependencies for all instances of a module are the same and so one instance cannot possibly depend on another. As a compromise then, here we introduce a new helper function that can recognize when a proposed edge is between two resource instances that belong to different instances of the same module, and thus allow us to skip actually creating those edges even though our imprecise analyses believe them to be needed. As well as significantly reducing the number of edges in situations where multi-instance resources appear inside multi-instance modules, this also fixes some potential cycles in situations where a single plan includes both destroying an instance of a module and creating a new instance of the same module: the dependencies between the objects in the instance being destroyed and the objects in the instance being created can, if allowed to connect, cause Terraform to believe that the create and the destroy both depend on one another even though there is no need for that to be true in practice. This involves a very specialized helper function to encode the situation where this exception applies. This function has an ugly name to reflect how specialized it is; it's not intended to be of any use outside of these three situations in particular. |
||
---|---|---|
.. | ||
child | ||
main.tf |