use existing State rather than Change.Before
The change was passed into the provisioner node because the normal NodeApplyableResourceInstance overwrites the prior state with the new state. This however doesn't matter here, because the resource destroy node does not do this. Also, even if the updated state were to be used for some reason with a create provisioner, it would be the correct state to use at that point.
This commit is contained in:
parent
a1181adca4
commit
e35524c7f0
|
@ -505,9 +505,6 @@ type EvalApplyProvisioners struct {
|
|||
|
||||
// When is the type of provisioner to run at this point
|
||||
When configs.ProvisionerWhen
|
||||
|
||||
// We use the stored change to get the previous resource values in the case of a destroy provisioner
|
||||
Change *plans.ResourceInstanceChange
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
|
@ -606,7 +603,7 @@ func (n *EvalApplyProvisioners) apply(ctx EvalContext, provs []*configs.Provisio
|
|||
|
||||
// this self is only used for destroy provisioner evaluation, and must
|
||||
// refer to the last known value of the resource.
|
||||
self := n.Change.Before
|
||||
self := (*n.State).Value
|
||||
|
||||
var evalScope func(EvalContext, hcl.Body, cty.Value, *configschema.Block) (cty.Value, tfdiags.Diagnostics)
|
||||
switch n.When {
|
||||
|
|
|
@ -394,7 +394,6 @@ func (n *NodeApplyableResourceInstance) managedResourceExecute(ctx EvalContext)
|
|||
CreateNew: &createNew,
|
||||
Error: &applyError,
|
||||
When: configs.ProvisionerWhenCreate,
|
||||
Change: diffApply,
|
||||
}
|
||||
_, err = applyProvisioners.Eval(ctx)
|
||||
if err != nil {
|
||||
|
|
|
@ -193,7 +193,6 @@ func (n *NodeDestroyResourceInstance) Execute(ctx EvalContext, op walkOperation)
|
|||
ResourceConfig: n.Config,
|
||||
Error: &provisionerErr,
|
||||
When: configs.ProvisionerWhenDestroy,
|
||||
Change: changeApply,
|
||||
}
|
||||
_, err := evalApplyProvisioners.Eval(ctx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue