From ecf72704c52d68ace0644ecc1553d1bc29672ab6 Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Tue, 10 Mar 2026 09:32:41 -0400 Subject: [PATCH] attach action config to config resource nodes --- internal/configs/action_test.go | 8 ++++ .../terraform/context_plan_actions_test.go | 48 +++---------------- 2 files changed, 15 insertions(+), 41 deletions(-) diff --git a/internal/configs/action_test.go b/internal/configs/action_test.go index 26fe50a6fe..a68a2e802a 100644 --- a/internal/configs/action_test.go +++ b/internal/configs/action_test.go @@ -10,6 +10,8 @@ import ( "github.com/hashicorp/hcl/v2/hclsyntax" "github.com/hashicorp/hcl/v2/hcltest" "github.com/zclconf/go-cty/cty" + + "github.com/hashicorp/terraform/internal/addrs" ) func TestDecodeActionBlock(t *testing.T) { @@ -80,7 +82,9 @@ func TestDecodeActionTriggerBlock(t *testing.T) { eventsListExpr := hcltest.MockExprList([]hcl.Expression{hcltest.MockExprTraversalSrc("after_create"), hcltest.MockExprTraversalSrc("after_update")}) fooActionExpr := hcltest.MockExprTraversalSrc("action.action_type.foo") + fooConfigAction := addrs.ConfigAction{Action: addrs.Action{Type: "action_type", Name: "foo"}} barActionExpr := hcltest.MockExprTraversalSrc("action.action_type.bar") + barConfigAction := addrs.ConfigAction{Action: addrs.Action{Type: "action_type", Name: "bar"}} fooAndBarExpr := hcltest.MockExprList([]hcl.Expression{fooActionExpr, barActionExpr}) // bad inputs! @@ -110,10 +114,12 @@ func TestDecodeActionTriggerBlock(t *testing.T) { { fooActionExpr, fooActionExpr.Range(), + fooConfigAction, }, { barActionExpr, barActionExpr.Range(), + barConfigAction, }, }, }, @@ -189,6 +195,7 @@ func TestDecodeActionTriggerBlock(t *testing.T) { { fooActionExpr, fooActionExpr.Range(), + fooConfigAction, }, }, }, @@ -215,6 +222,7 @@ func TestDecodeActionTriggerBlock(t *testing.T) { { fooActionExpr, fooActionExpr.Range(), + fooConfigAction, }, }, }, diff --git a/internal/terraform/context_plan_actions_test.go b/internal/terraform/context_plan_actions_test.go index c98ef4dd32..46b5f5b812 100644 --- a/internal/terraform/context_plan_actions_test.go +++ b/internal/terraform/context_plan_actions_test.go @@ -100,13 +100,12 @@ func TestContextPlan_actions(t *testing.T) { } for topic, tcs := range map[string]map[string]struct { - toBeImplemented bool - module map[string]string - buildState func(*states.SyncState) - planActionFn func(*testing.T, providers.PlanActionRequest) providers.PlanActionResponse - planResourceFn func(*testing.T, providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse - readResourceFn func(*testing.T, providers.ReadResourceRequest) providers.ReadResourceResponse - planOpts *PlanOpts + module map[string]string + buildState func(*states.SyncState) + planActionFn func(*testing.T, providers.PlanActionRequest) providers.PlanActionResponse + planResourceFn func(*testing.T, providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse + readResourceFn func(*testing.T, providers.ReadResourceRequest) providers.ReadResourceResponse + planOpts *PlanOpts expectPlanActionCalled bool @@ -712,36 +711,7 @@ resource "test_object" "a" { ) }, }, - "splat is not supported": { - module: map[string]string{ - "main.tf": ` -action "test_action" "hello" { - count = 42 -} -resource "test_object" "a" { - lifecycle { - action_trigger { - events = [before_create] - actions = [action.test_action.hello[*]] - } - } -} -`, - }, - expectPlanActionCalled: false, - expectPlanDiagnostics: func(m *configs.Config) tfdiags.Diagnostics { - return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Invalid action expression", - Detail: "Unexpected expression found in action_triggers.actions.", - Subject: &hcl.Range{ - Filename: filepath.Join(m.Module.SourceDir, "main.tf"), - Start: hcl.Pos{Line: 9, Column: 18, Byte: 159}, - End: hcl.Pos{Line: 9, Column: 47, Byte: 186}, - }, - }) - }, - }, + "multiple events triggering in same action trigger": { module: map[string]string{ "main.tf": ` @@ -3905,10 +3875,6 @@ resource "test_object" "b" { t.Run(topic, func(t *testing.T) { for name, tc := range tcs { t.Run(name, func(t *testing.T) { - if tc.toBeImplemented { - t.Skip("Test not implemented yet") - } - opts := SimplePlanOpts(plans.NormalMode, InputValues{}) if tc.planOpts != nil { opts = tc.planOpts