-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Fixed variables not being in scope for destroy -target on modules #9021
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow @kyhavlov this is some great Friday graph diving you've done here!
This looks basically perfect - I've included a few nits on details, but otherwise this is great! 💟
} | ||
|
||
h := new(HookRecordApplyOrder) | ||
h.Active = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this Hook is not used in this test.
Targets: []string{"module.child"}, | ||
}) | ||
|
||
// First plan and apply a create operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't applicable here anymore, since this is the destroy.
Providers: map[string]ResourceProviderFactory{ | ||
"aws": testProviderFuncFixed(p), | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above WritePlan
/ ReadPlan
dance is meant to emulate writing out to a tfplan
file. It's unnecessary here, since the bug reproduces w/o it.
@@ -86,6 +86,14 @@ func (t *TargetsTransformer) selectTargetedNodes( | |||
var err error | |||
if t.Destroy { | |||
deps, err = g.Descendents(v) | |||
|
|||
// Select any variables that we depend on in case we need them later for interpolating in count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: wrap comment at 80 columns.
4c4178e
to
3a2819d
Compare
@phinze addressed the comments and cleaned up the test. I was going add a test for the nested module case, but I hit the issue with Terraform not including child modules of a module when using -target, so that will have to be another PR. |
LGTM |
Got the error this was supposed to fix on 0.7.4. Upgraded to 0.7.6. Now I get the following when doing
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Addresses the bug in #8146. The call to
selectTargetedNodes()
was only returning the resource and not the variable that it depended on to interpolate its count, so the variable got removed from the graph and wasn't in scope for later interpolations, causing theunknown variable accessed
error.@phinze