Skip to content

Commit

Permalink
Do not execute build on bundle destroy (#1882)
Browse files Browse the repository at this point in the history
## Changes
There's no value in building artifacts on destroy because they are just
removed from workspace as part of destroy.
  • Loading branch information
andrewnester authored Nov 7, 2024
1 parent b6a376b commit 162aa21
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/bundle/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/cli/bundle/phases"
"github.com/databricks/cli/cmd/bundle/utils"
"github.com/databricks/cli/cmd/root"
Expand Down Expand Up @@ -62,7 +63,12 @@ func newDestroyCommand() *cobra.Command {

diags = bundle.Apply(ctx, b, bundle.Seq(
phases.Initialize(),
phases.Build(),
// We need to resolve artifact variable (how we do it in build phase)
// because some of the to-be-destroyed resource might use this variable.
// Not resolving might lead to terraform "Reference to undeclared resource" error
mutator.ResolveVariableReferences(
"artifacts",
),
phases.Destroy(),
))
if err := diags.Error(); err != nil {
Expand Down

0 comments on commit 162aa21

Please sign in to comment.