hashicorp/terraform · info

errDestroyDiscarded

errDestroyDiscarded

Error message

Destroy discarded.

What it means

Returned by the Terraform Cloud backend when a destroy run is discarded before it executes. Analogous to errApplyDiscarded but specific to destroy-mode operations (op.PlanMode == plans.DestroyMode). Set in backend_common.go:492-493 when the discarded run was a destroy operation.

Source

Thrown at internal/cloud/errors.go:18

// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1

package cloud

import (
	"errors"
	"fmt"
	"strings"

	"github.com/hashicorp/terraform/internal/tfdiags"
	"github.com/zclconf/go-cty/cty"
)

// String based errors
var (
	errApplyDiscarded                    = errors.New("Apply discarded.")
	errDestroyDiscarded                  = errors.New("Destroy discarded.")
	errRunApproved                       = errors.New("approved using the UI or API")
	errRunDiscarded                      = errors.New("discarded using the UI or API")
	errRunOverridden                     = errors.New("overridden using the UI or API")
	errApplyNeedsUIConfirmation          = errors.New("Cannot confirm apply due to -input=false. Please handle run confirmation in the UI.")
	errPolicyOverrideNeedsUIConfirmation = errors.New("Cannot override soft failed policy checks when -input=false. Please open the run in the UI to override.")
)

// Diagnostic error messages
var (
	invalidWorkspaceConfigMissingValues = tfdiags.AttributeValue(
		tfdiags.Error,
		"Invalid workspaces configuration",
		fmt.Sprintf("Missing workspace mapping strategy. Either workspace \"tags\" or \"name\" is required.\n\n%s", workspaceConfigurationHelp),
		cty.Path{cty.GetAttrStep{Name: "workspaces"}},
	)

	invalidWorkspaceConfigMisconfiguration = tfdiags.AttributeValue(
		tfdiags.Error,

View on GitHub (pinned to d32a084675)

Solutions

  1. Re-run 'terraform destroy' if the discard was unintentional.
  2. If discarding was intentional, no further action is needed.
  3. Use -auto-approve with destroy to bypass the interactive confirmation in automated contexts.
  4. Ensure no concurrent UI/API discard operations run alongside CLI destroy commands.

Example fix

// before
terraform destroy
// user types 'no' -> Destroy discarded.

// after
terraform destroy -auto-approve
Defensive patterns

Strategy: try-catch

Try / catch

// if errors.Is(err, cloud.ErrDestroyDiscarded) {
//     log.Info("destroy was discarded by user or externally")
//     return nil
// }

Prevention

When it happens

Trigger: Running 'terraform destroy' against a cloud-backed workspace and declining the destroy confirmation prompt, or having the destroy run discarded externally via UI/API while the CLI waits. backend_common.go:492 checks op.PlanMode == plans.DestroyMode to select this error over errApplyDiscarded.

Common situations: An operator cancels a destructive destroy at the last-second confirmation; a teammate discards the run in TFC UI; automation sends a Discard API call during a destroy.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/35374b6894cb392c. Report an issue: GitHub.