hashicorp/terraform · error

error: using a saved cloud plan when executing Terraform loc

Error message

error: using a saved cloud plan when executing Terraform locally is not supported

What it means

Returned by Local.localRun when op.PlanFile.IsCloud() is true. A cloud-saved plan (produced and stored by Terraform Cloud/Enterprise) can only be applied by the cloud backend; the local execution backend cannot execute it. This is a hard unsupported-operation guard, not a transient failure.

Source

Thrown at internal/backend/local/backend_local.go:91

	}

	ret := &backendrun.LocalRun{
		PolicyClient: op.PolicyClient,
	}

	// Initialize our context options
	var coreOpts terraform.ContextOpts
	if v := b.ContextOpts; v != nil {
		coreOpts = *v
	}
	coreOpts.UIInput = op.UIIn
	coreOpts.Hooks = op.Hooks
	coreOpts.TracingContext = ctx

	var ctxDiags tfdiags.Diagnostics
	var configSnap *configload.Snapshot
	if op.PlanFile.IsCloud() {
		diags = diags.Append(fmt.Errorf("error: using a saved cloud plan when executing Terraform locally is not supported"))
		return ret, nil, nil, diags
	}

	if lp, ok := op.PlanFile.Local(); ok {
		var stateMeta *statemgr.SnapshotMeta
		// If the statemgr implements our optional PersistentMeta interface then we'll
		// additionally verify that the state snapshot in the plan file has
		// consistent metadata, as an additional safety check.
		if sm, ok := s.(statemgr.PersistentMeta); ok {
			m := sm.StateSnapshotMeta()
			stateMeta = &m
		}
		log.Printf("[TRACE] backend/local: populating backendrun.LocalRun from plan file")
		ret, configSnap, ctxDiags = b.localRunForPlanFile(op, lp, ret, &coreOpts, stateMeta)
		if ctxDiags.HasErrors() {
			diags = diags.Append(ctxDiags)
			return ret, nil, nil, diags
		}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Apply the cloud-saved plan from within Terraform Cloud/Enterprise (the cloud backend) instead of locally.
  2. Generate a fresh local plan with terraform plan -out=tfplan and apply that locally with terraform apply tfplan.
  3. Switch the configuration's backend to 'cloud' so the local CLI applies via the cloud run.

Example fix

# before
terraform plan -out=plan    # in TFC, then download and:
terraform apply plan          # locally -> error
# after (regenerate locally)
terraform plan -out=tfplan
terraform apply tfplan
Defensive patterns

Strategy: validation

Validate before calling

// Reject cloud plan files before attempting local apply.
if op.PlanFile.IsCloud() {
    return errors.New("cannot apply a cloud-saved plan locally; apply via TFC/TFE or regenerate locally")
}

Prevention

When it happens

Trigger: Running terraform apply with a plan file that was saved to Terraform Cloud (e.g. via a cloud-backed plan run) while using a non-cloud (local or other) backend. The local backend's LocalRun path detects IsCloud() and aborts.

Common situations: Exporting/applying a plan generated in a TFC/TFE workspace locally; switching from cloud to local backend without regenerating the plan; CI that downloads a cloud plan and tries to apply it locally.

Related errors


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