kubernetes/kops · error
duplicate variable found: %s
Error message
duplicate variable found: %s
What it means
Thrown by TerraformWriter.GetOutputs when two distinct output entries sanitize to the same Terraform output name — i.e. the outputs list contains a duplicate after name sanitization (dashes/cases collapsing to the same tfName). Terraform does not allow duplicate output names, so the generated HCL would be invalid.
Source
Thrown at upup/pkg/fi/cloudup/terraformWriter/writer.go:259
tfName := sanitizeName(res.ResourceName)
if resources[tfName] != nil {
return nil, fmt.Errorf("duplicate resource found: %s.%s", res.ResourceType, tfName)
}
resources[tfName] = res.Item
}
return resourcesByType, nil
}
func (t *TerraformWriter) GetOutputs() (map[string]OutputValue, error) {
values := map[string]OutputValue{}
for _, v := range t.outputs {
tfName := sanitizeName(v.Key)
if _, found := values[tfName]; found {
return nil, fmt.Errorf("duplicate variable found: %s", tfName)
}
deduped, err := dedupLiterals(v.ValueArray)
if err != nil {
return nil, err
}
values[tfName] = OutputValue{
Value: v.Value,
ValueArray: deduped,
}
}
return values, nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Find which two output keys sanitize to the same name (the error prints the tfName) and rename one in the task definitions
- Avoid emitting both a raw and a sanitized variant of the same key from tasks
- Add a unit check when adding new outputs so names stay unique after sanitization
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/terraformWriter/writer.go:259 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/fe1f7b4fa506baaa.
Report an issue: GitHub.