From 6bb50f4056cac17065eb40e193c6e36b4d342dc5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:49:18 +0000 Subject: [PATCH] Backport of actions: allow invoke only on local execution while TFC adds support into v1.14 (#37654) * backport of commit fa389d2e183654e9d9595b571edc2e52cc5693f1 * backport of commit 941d46f33416fe9483b954fdf52d443caf1c323b --------- Co-authored-by: Liam Cervante --- internal/command/plan.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/command/plan.go b/internal/command/plan.go index a6f0b14001..73336696c4 100644 --- a/internal/command/plan.go +++ b/internal/command/plan.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/hashicorp/terraform/internal/backend/backendrun" + "github.com/hashicorp/terraform/internal/backend/local" "github.com/hashicorp/terraform/internal/command/arguments" "github.com/hashicorp/terraform/internal/command/views" "github.com/hashicorp/terraform/internal/tfdiags" @@ -78,6 +79,18 @@ func (c *PlanCommand) Run(rawArgs []string) int { return 1 } + if len(args.Operation.ActionTargets) > 0 { + if _, ok := be.(*local.Local); !ok { + // Temporarily block invoking actions when executing anything other + // than locally. + // TODO: Remove this when TFC supports remote operation of action + // invoke plans. + diags = diags.Append(tfdiags.Sourceless(tfdiags.Error, "Invalid argument", "The -invoke argument can currently only be used when Terraform is executing locally.")) + view.Diagnostics(diags) + return 1 + } + } + // Build the operation request opReq, opDiags := c.OperationRequest(be, view, args.ViewType, args.Operation, args.OutPath, args.GenerateConfigPath) diags = diags.Append(opDiags)