hashicorp/terraform · error
Raw output format is only supported for single outputs
Error message
Raw output format is only supported for single outputs
What it means
Returned by the raw output renderer when `terraform output -raw` is invoked without naming a specific output. The -raw mode renders a single value directly (no key, no quotes); with zero or multiple outputs there is no single value to emit, so it errors rather than guessing. This is a usage error, not a runtime/environment failure.
Source
Thrown at internal/command/views/output.go:124
// output values directly and without quotes or other formatting. This is
// intended for use in shell scripting or other environments where the exact
// type of an output value is not important.
type OutputRaw struct {
view *View
}
var _ Output = (*OutputRaw)(nil)
func (v *OutputRaw) Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics
if len(outputs) == 0 {
diags = diags.Append(noOutputsWarning())
return diags
}
if name == "" {
diags = diags.Append(fmt.Errorf("Raw output format is only supported for single outputs"))
return diags
}
output, ok := outputs[name]
if !ok {
diags = diags.Append(missingOutputError(name))
return diags
}
strV, err := convert.Convert(output.Value, cty.String)
if err != nil {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Unsupported value for raw output",
fmt.Sprintf(
"The -raw option only supports strings, numbers, and boolean values, but output value %q is %s.\n\nUse the -json option for machine-readable representations of output values that have complex types.",
name, output.Value.Type().FriendlyName(),
),View on GitHub (pinned to c9def3e214)
Solutions
- Pass the specific output name: `terraform output -raw <name>`.
- List available outputs first with `terraform output` (no -raw) to find the exact name.
- For multiple/all values in a script, use `terraform output -json` and parse with jq instead of -raw.
Example fix
# before terraform output -raw # Raw output format is only supported for single outputs # after terraform output -raw instance_ip # or, for many values terraform output -json | jq -r '.instance_ip.value'
Defensive patterns
Strategy: validation
Validate before calling
// before using -raw, ensure exactly one output name is requested
func requireSingleOutputName(args []string) error {
if len(args) != 1 {
return fmt.Errorf("-raw requires exactly one output name")
}
return nil
} Prevention
- Always pass a specific output name with -raw.
- List outputs first with `terraform output` to confirm names.
- Use `terraform output -json` for multi-value extraction in scripts.
- Validate script inputs before invoking terraform output -raw.
When it happens
Trigger: Running `terraform output -raw` with no output NAME argument (expecting it to print all), or with multiple outputs in state and no name argument. Also when the command is invoked as `terraform output -raw NAME EXTRA`.
Common situations: Scripting `terraform output -raw` and forgetting the output name; copy-pasting from a -json example; expecting -raw to behave like default (list all) output.
Related errors
- Expected a single argument: NAME.
- Too many command line arguments. Did you mean to use -chdir?
- Expected a single argument: NAME.
- Expected a single argument: NAME.
- Error selecting workspace: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/b5d7bbcdc11ffa78.
Report an issue: GitHub.