: core: Fix destroy w/module vars used in counts #6753
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the same PR as #6723 but targeted at the 0.7 release rather than 0.6.17.
This PR combines the work of @phinze in #6704 and @vancluever on the paybyphone fork of Terraform.
First from @phinze:
A new problem was introduced by the prior fixes for destroy interpolation messages when resources depend on module variables with a count attribute, this makes the variable crucial for properly building the graph - even in destroys. So removing all module variables from the graph as noops was overzealous.
By borrowing the logic in DestroyEdgeInclude we are able to determine if we need to keep a given module variable relatively easily.
I'd like to overhaul the Destroy: true implementation so that it does not depend on config at all, but I want to continue for now with the targeted fixes that we can backport into the 0.6 series.
Then from @vancluever in paybyphone/terraform@c975906:
Building on b10564a, adding tweaks that allow the module var count search to act recursively, ensuring that a sitaution where something like var.top gets passed to module middle, as var.middle, and then to
module bottom, as var.bottom, which is then used in a resource count.