hashicorp/terraform · error

Migration aborted by user.

Error message

Migration aborted by user.

What it means

In Meta.backendMigrateState_S_S (meta_backend_migrate.go:186), the user was asked 'Do you want to migrate all workspaces to <destination>?' and declined (confirm returned false). Terraform treats any non-confirmation as an explicit abort of the multi-state migration, so init stops. This is an intentional user decision, not a fault.

Source

Thrown at internal/command/meta_backend_migrate.go:186

	if !migrate {
		var err error
		// Ask the user if they want to migrate their existing remote state
		migrate, err = m.confirm(&terraform.InputOpts{
			Id: "backend-migrate-multistate-to-multistate",
			Query: fmt.Sprintf(
				"Do you want to migrate all workspaces to %q?",
				opts.DestinationType),
			Description: fmt.Sprintf(
				strings.TrimSpace(inputBackendMigrateMultiToMulti),
				opts.SourceType, opts.DestinationType),
		})
		if err != nil {
			return fmt.Errorf(
				"Error asking for state migration action: %s", err)
		}
	}
	if !migrate {
		return fmt.Errorf("Migration aborted by user.")
	}

	// Read all the states
	sourceWorkspaces, wDiags := opts.Source.Workspaces()
	if wDiags.HasErrors() {
		return fmt.Errorf(strings.TrimSpace(
			errMigrateLoadStates), opts.SourceType, wDiags.Err())
	}
	if wDiags.HasWarnings() {
		log.Printf("[WARN] backendMigrateState_S_S: warning(s) returned when getting workspaces from source backend: %s", wDiags.ErrWithWarnings())
	}

	// Sort the states so they're always copied alphabetically
	sort.Strings(sourceWorkspaces)

	// Go through each and migrate
	for _, name := range sourceWorkspaces {
		// Copy the same names

View on GitHub (pinned to c9def3e214)

Solutions

  1. If you do want to migrate, re-run and confirm; or use `terraform init -migrate-state` to skip the prompt.
  2. If you intended to discard state instead, use `terraform init -reconfigure` to reinitialize without migrating.
  3. Verify source and destination backends are correct before confirming a migration.
  4. Ensure automation sends a confirming value or uses the appropriate flag to avoid an accidental abort.

Example fix

// before: answered 'no'  -> 'Migration aborted by user.'
// after: terraform init -migrate-state   # to migrate, OR
terraform init -reconfigure   # to discard saved state
Defensive patterns

Strategy: validation

Validate before calling

// Decide migration vs reconfigure up front and pass the right flag to avoid an accidental abort.
func chooseInitFlags(discardState bool, migrateWanted bool) []string {
    if discardState { return []string{"-reconfigure"} }
    if migrateWanted { return []string{"-migrate-state"} }
    return nil
}

Prevention

When it happens

Trigger: Answering 'no' (or anything other than confirmation) at the migrate-all-workspaces prompt during a multi-state backend migration; automation feeding a non-confirming value.

Common situations: An operator choosing not to migrate (e.g. wanting to inspect first), running with `-reconfigure` intent but hitting the migrate prompt instead, or automation answering incorrectly.

Related errors


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