Skip to content
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

Merged
merged 1 commit into from
Sep 23, 2016

Conversation

kyhavlov
Copy link
Contributor

@kyhavlov kyhavlov commented Sep 23, 2016

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 the unknown variable accessed error.

@phinze

Copy link
Contributor

@phinze phinze left a 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
Copy link
Contributor

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
Copy link
Contributor

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),
},
})
Copy link
Contributor

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
Copy link
Contributor

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.

@kyhavlov
Copy link
Contributor Author

@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.

@phinze
Copy link
Contributor

phinze commented Sep 23, 2016

LGTM

@phinze phinze merged commit 12e76c0 into hashicorp:master Sep 23, 2016
@kyhavlov kyhavlov deleted the destroy_target_fix branch September 23, 2016 23:32
@matthughes
Copy link

matthughes commented Oct 18, 2016

Got the error this was supposed to fix on 0.7.4. Upgraded to 0.7.6. Now I get the following when doing terraform destroy -target=...:

Error configuring: 1 error(s) occurred:

* Error reading data.template_file.master_config count: strconv.ParseInt: parsing "${var.master_count}": invalid syntax

@ghost
Copy link

ghost commented Apr 21, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants