mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
3b2282ca57
Fixes #10338 The destruction step for a resource was included the deposed resources for _all_ resources with that name (ignoring the "index"). For example: `aws_instance.foo.0` was including destroying deposed for `aws_instance.foo.1`. This changes the config to the deposed transformer to properly include that index. This change includes a larger change of changing `stateId` to include the index. This affected more parts but was ultimately the issue in question.
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package terraform
|
|
|
|
// NodePlannableResourceOrphan represents a resource that is "applyable":
|
|
// it is ready to be applied and is represented by a diff.
|
|
type NodePlannableResourceOrphan struct {
|
|
*NodeAbstractResource
|
|
}
|
|
|
|
func (n *NodePlannableResourceOrphan) Name() string {
|
|
return n.NodeAbstractResource.Name() + " (orphan)"
|
|
}
|
|
|
|
// GraphNodeEvalable
|
|
func (n *NodePlannableResourceOrphan) EvalTree() EvalNode {
|
|
addr := n.NodeAbstractResource.Addr
|
|
|
|
// stateId is the ID to put into the state
|
|
stateId := addr.stateId()
|
|
|
|
// Build the instance info. More of this will be populated during eval
|
|
info := &InstanceInfo{
|
|
Id: stateId,
|
|
Type: addr.Type,
|
|
ModulePath: normalizeModulePath(addr.Path),
|
|
}
|
|
|
|
// Declare a bunch of variables that are used for state during
|
|
// evaluation. Most of this are written to by-address below.
|
|
var diff *InstanceDiff
|
|
var state *InstanceState
|
|
|
|
return &EvalSequence{
|
|
Nodes: []EvalNode{
|
|
&EvalReadState{
|
|
Name: stateId,
|
|
Output: &state,
|
|
},
|
|
&EvalDiffDestroy{
|
|
Info: info,
|
|
State: &state,
|
|
Output: &diff,
|
|
},
|
|
&EvalCheckPreventDestroy{
|
|
Resource: n.Config,
|
|
ResourceId: stateId,
|
|
Diff: &diff,
|
|
},
|
|
&EvalWriteDiff{
|
|
Name: stateId,
|
|
Diff: &diff,
|
|
},
|
|
},
|
|
}
|
|
}
|