hashicorp/terraform · warning

Apply discarded.

Error message

Apply discarded.

What it means

errApplyDiscarded (internal/backend/remote/backend_common.go:26) is returned by the remote (TFE/TFC) backend's confirm() flow when a run is discarded. It is set when the run transitions to RunDiscarded (line 541) or when the user does not type 'yes' and the run is discarded via the API (line 597). It signals that the apply phase was intentionally aborted, not that it failed technically.

Source

Thrown at internal/backend/remote/backend_common.go:26

	"context"
	"errors"
	"fmt"
	"io"
	"math"
	"strconv"
	"strings"
	"time"

	tfe "github.com/hashicorp/go-tfe"

	"github.com/hashicorp/terraform/internal/backend/backendrun"
	"github.com/hashicorp/terraform/internal/logging"
	"github.com/hashicorp/terraform/internal/plans"
	"github.com/hashicorp/terraform/internal/terraform"
)

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")
)

var (
	backoffMin = 1000.0
	backoffMax = 3000.0

	runPollInterval = 3 * time.Second
)

// backoff will perform exponential backoff based on the iteration and
// limited by the provided min and max (in milliseconds) durations.
func backoff(min, max float64, iter int) time.Duration {
	backoff := math.Pow(2, float64(iter)/5) * min
	if backoff > max {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run 'terraform apply' and confirm with 'yes' if you still want the changes.
  2. If the discard came from the UI/API, coordinate with teammates to avoid concurrent discards.
  3. Use -auto-approve (where appropriate) to avoid the interactive confirmation, or ensure the confirming user types 'yes'.
Defensive patterns

Strategy: try-catch

Try / catch

// errApplyDiscarded is an expected user-cancel; report it, do not retry.
if err := b.confirm(stopCtx, op, opts, r, "yes"); err != nil {
    if errors.Is(err, errApplyDiscarded) {
        return errors.New("apply discarded: re-run 'terraform apply' and confirm 'yes' to proceed")
    }
    return err
}

Prevention

When it happens

Trigger: During a remote apply, the user types something other than 'yes' at the confirmation prompt (the run is discarded via Runs.Discard); or the run is discarded through the TFE/TFC UI or API while the CLI is waiting. For destroy operations the parallel errDestroyDiscarded is used instead.

Common situations: User typing 'no' or an empty/typo at the apply confirmation in a remote run; a teammate discarding the run from the TFC UI while the CLI waits; CI auto-discarding via API; the run being discarded by a policy/gate externally.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/12553fd9bb82a9d8. Report an issue: GitHub.