hashicorp/packer · error
ssh_private_ip is not a boolean, %s
Error message
ssh_private_ip is not a boolean, %s
What it means
The amazon-private_ip fixer migrates the deprecated builder-level `ssh_private_ip` key to `ssh_interface`. If the value is neither a bool nor a string parseable by strconv.ParseBool ("true","false","1","0", etc.), the fixer aborts with this error wrapping the parse error.
Source
Thrown at fix/fixer_amazon_private_ip.go:65
if !strings.HasPrefix(builderType, "amazon-") {
continue
}
// if ssh_interface already set, do nothing
if _, ok := builder["ssh_interface"]; ok {
continue
}
privateIPi, ok := builder["ssh_private_ip"]
if !ok {
continue
}
privateIP, ok := privateIPi.(bool)
if !ok {
var err error
privateIP, err = strconv.ParseBool(privateIPi.(string))
if err != nil {
return nil, fmt.Errorf("ssh_private_ip is not a boolean, %s", err)
}
}
delete(builder, "ssh_private_ip")
if privateIP {
builder["ssh_interface"] = "private_ip"
} else {
builder["ssh_interface"] = "public_ip"
}
}
input["builders"] = tpl.Builders
return input, nil
}
func (FixerAmazonPrivateIP) Synopsis() string {
return "Replaces `\"ssh_private_ip\": true` in amazon builders with `\"ssh_interface\": \"private_ip\"`"
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Edit the template so ssh_private_ip is a JSON boolean true/false (or string "true"/"false")
- Let the fixer complete, then remove ssh_private_ip in favor of the generated ssh_interface key
- If you want 'private_ip' semantics, after fixing use ssh_interface = "private_ip"
Example fix
// before "ssh_private_ip": "yes" // after "ssh_private_ip": true
Defensive patterns
Strategy: validation
Validate before calling
// pre-check fixer input in CI
if v, ok := tpl["ssh_private_ip"]; ok {
switch v.(type) { case bool, string: if _, err := strconv.ParseBool(fmt.Sprint(v)); err != nil && !ok2(v) { /* reject */ } }
} Type guard
func isBoolLike(v interface{}) bool {
if _, ok := v.(bool); ok { return true }
s, ok := v.(string); if !ok { return false }
_, err := strconv.ParseBool(s); return err == nil
} Prevention
- Keep booleans as JSON booleans in templates
- Audit legacy templates with `packer fix` in a dry CI step before migration
- Avoid template engines that stringify booleans ('yes'/'on')
When it happens
Trigger: Running `packer fix` on a JSON template where amazon builders contain `ssh_private_ip` set to a non-boolean, unparseable value like "yes", "on", or a number.
Common situations: Hand-edited legacy templates, templates generated by other tooling using YAML-ish truthy strings, or values produced by template engines that stringified booleans.
Related errors
- unsupported reftype %q, must be either 'data', 'local' or 'v
- malformed datasource reference %q, data sources must be comp
- decode attestation envelope %q: %w
- decode attestation statement: %w
- Invalid remote protocol: %q, expected something like '%s.%s'
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/2ef720c1b5b50b0f.
Report an issue: GitHub.