hashicorp/terraform · error

Error asking for input to configure backend %q: %s

Error message

Error asking for input to configure backend %q: %s

What it means

In Meta.backendInitFromConfig (meta_backend.go:2719), when interactive input is enabled (m.Input()) and required backend arguments are missing, Terraform prompts the user via inputForSchema to fill them in. If that prompting itself fails (e.g. no TTY, EOF on stdin, or a UI input error), this wraps the failure. It is about the INPUT mechanism, not about invalid config values.

Source

Thrown at internal/command/meta_backend.go:2719

	diags = diags.Append(hclDiags)
	if hclDiags.HasErrors() {
		return nil, cty.NilVal, diags
	}

	if !configVal.IsWhollyKnown() {
		diags = diags.Append(tfdiags.Sourceless(
			tfdiags.Error,
			"Unknown values within backend definition",
			"The `terraform` configuration block should contain only concrete and static values. Another diagnostic should contain more information about which part of the configuration is problematic."))
		return nil, cty.NilVal, diags
	}

	// TODO: test
	if m.Input() {
		var err error
		configVal, err = m.inputForSchema(configVal, schema)
		if err != nil {
			diags = diags.Append(fmt.Errorf("Error asking for input to configure backend %q: %s", c.Type, err))
		}

		// We get an unknown here if the if the user aborted input, but we can't
		// turn that into a config value, so set it to null and let the provider
		// handle it in PrepareConfig.
		if !configVal.IsKnown() {
			configVal = cty.NullVal(configVal.Type())
		}
	}

	newVal, validateDiags := b.PrepareConfig(configVal)
	diags = diags.Append(validateDiags.InConfigBody(c.Config, ""))
	if validateDiags.HasErrors() {
		return nil, cty.NilVal, diags
	}

	configureDiags := b.Configure(newVal)
	diags = diags.Append(configureDiags.InConfigBody(c.Config, ""))

View on GitHub (pinned to c9def3e214)

Solutions

  1. Provide all required backend arguments in the config or via `-backend-config=` so no prompt is needed.
  2. Run with `-input=false` in non-interactive environments and supply values explicitly.
  3. If you expect a TTY, ensure the terminal/PTY is attached and stdin is open.
  4. Check the wrapped `%s` for the specific input error (EOF, not a terminal).

Example fix

// before: terraform init   (CI, no TTY; fails: Error asking for input to configure backend)
// after: terraform init -input=false -backend-config="bucket=mybucket" -backend-config="key=prod.tfstate"
Defensive patterns

Strategy: validation

Validate before calling

// In non-interactive contexts, ensure no required backend attribute is missing before init.
func backendConfigCompleteForCI(c *configs.Backend) error {
    if os.Getenv("CI") == "" { return nil }
    // Required: ensure all backend attrs supplied; else pass -input=false with -backend-config.
    return validateNoMissingAttrs(c)
}

Prevention

When it happens

Trigger: Running `terraform init` in a non-interactive context (piped/closed stdin, CI with no TTY) where a backend argument is missing so Terraform tries to prompt and input fails; a custom UI/input implementation returning an error.

Common situations: CI pipelines or containers with no TTY where required backend attributes are omitted and -input=true (the default); scripts that close stdin.

Related errors


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