Skip to content

Commit 794a641

Browse files
committed
parse action expression during ActionPlanTransformer transform
1 parent db63709 commit 794a641

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

internal/terraform/node_resource_plan_instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func (n *NodePlannableResourceInstance) managedResourceExecute(ctx EvalContext)
399399
}
400400
}
401401

402-
// FIXME: here we udpate the change to reflect the reason for
402+
// FIXME: here we update the change to reflect the reason for
403403
// replacement, but we still overload forceReplace to get the correct
404404
// change planned.
405405
if len(n.replaceTriggeredBy) > 0 {
@@ -507,7 +507,7 @@ func (n *NodePlannableResourceInstance) managedResourceExecute(ctx EvalContext)
507507

508508
// Even if we don't plan changes, we do still need to at least update
509509
// the working state to reflect the refresh result. If not, then e.g.
510-
// any output values refering to this will not react to the drift.
510+
// any output values referring to this will not react to the drift.
511511
// (Even if we didn't actually refresh above, this will still save
512512
// the result of any schema upgrading we did in readResourceInstanceState.)
513513
diags = diags.Append(n.writeResourceInstanceState(ctx, instanceRefreshState, workingState))

internal/terraform/transform_action_plan.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/hashicorp/terraform/internal/addrs"
1010
"github.com/hashicorp/terraform/internal/configs"
1111
"github.com/hashicorp/terraform/internal/dag"
12+
"github.com/hashicorp/terraform/internal/lang/langrefs"
1213
)
1314

1415
type ActionPlanTransformer struct {
@@ -29,7 +30,7 @@ func (t *ActionPlanTransformer) transform(g *Graph, config *configs.Config) erro
2930
return err
3031
}
3132

32-
// Transform all the children without generating config.
33+
// Transform all the children.
3334
for _, c := range config.Children {
3435
if err := t.transform(g, c); err != nil {
3536
return err
@@ -66,14 +67,15 @@ func (t *ActionPlanTransformer) transformSingle(g *Graph, config *configs.Config
6667
priorNodes := []*nodeActionTriggerPlanExpand{}
6768
for i, at := range r.Managed.ActionTriggers {
6869
for j, action := range at.Actions {
69-
ref, parseRefDiags := addrs.ParseRef(action.Traversal)
70+
ref, parseRefDiags := langrefs.ReferencesInExpr(addrs.ParseRef, action.Expr)
7071
if parseRefDiags != nil {
7172
return parseRefDiags.Err()
7273
}
74+
7375
var instance addrs.ConfigAction
7476
actionInstanceKey := addrs.NoKey
7577

76-
switch ai := ref.Subject.(type) {
78+
switch ai := ref[0].Subject.(type) {
7779
case addrs.Action:
7880
instance = ai.InModule(config.Path)
7981
case addrs.ActionInstance:
@@ -105,7 +107,7 @@ func (t *ActionPlanTransformer) transformSingle(g *Graph, config *configs.Config
105107
resourceAddress: resourceAddr,
106108
actionTriggerBlockIndex: i,
107109
actionListIndex: j,
108-
invokingSubject: action.Traversal.SourceRange().Ptr(),
110+
invokingSubject: action.Expr.Range().Ptr(),
109111
},
110112
}
111113

0 commit comments

Comments
 (0)