kubernetes/kops · error
ID must be set, if ElasticIP is shared: %v
Error message
ID must be set, if ElasticIP is shared: %v
What it means
In ElasticIP.RenderTerraform, when the EIP is marked Shared (managed outside kOps, e.g. an existing NAT gateway EIP), kOps does not create terraform resources for it and requires the existing allocation ID. If e.ID is nil it throws 'ID must be set, if ElasticIP is shared: %v'.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/elastic_ip.go:284
}
} else {
// TODO: Figure out what we can do. We're sort of stuck between wanting to have one code-path with
// terraform, and having a bigger "window of loss" here before we create the NATGateway
klog.V(2).Infof("ElasticIP %q not tagged on subnet; risk of leaking", fi.ValueOf(publicIp))
}
return nil
}
type terraformElasticIP struct {
Domain *string `cty:"domain"`
Tags map[string]string `cty:"tags"`
}
func (_ *ElasticIP) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *ElasticIP) error {
if fi.ValueOf(e.Shared) {
if e.ID == nil {
return fmt.Errorf("ID must be set, if ElasticIP is shared: %v", e)
}
klog.V(4).Infof("reusing existing ElasticIP with id %q", aws.ToString(e.ID))
return nil
}
tf := &terraformElasticIP{
Domain: aws.String("vpc"),
Tags: e.Tags,
}
return t.RenderResource("aws_eip", *e.Name, tf)
}
func (e *ElasticIP) TerraformLink() *terraformWriter.Literal {
if fi.ValueOf(e.Shared) {
if e.ID == nil {
klog.Fatalf("ID must be set, if ElasticIP is shared: %v", e)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Set the ID field to the existing EIP allocation ID (eipalloc-...) on the shared ElasticIP task in the cluster spec
- Find the correct ID with aws ec2 describe-addresses --filters Name=public-ip,Values=<ip>
- If the EIP should be kOps-managed instead, remove shared: true so RenderTerraform generates the resource
- Re-run kops update cluster --target=terraform after the spec fix
Example fix
// before elasticIPs: - shared: true // ID missing // after elasticIPs: - shared: true id: eipalloc-0abc123def4567890
Defensive patterns
Strategy: validation
Validate before calling
if fi.ValueOf(shared) && id == nil {
return errors.New("shared ElasticIP requires an existing eipalloc-* ID")
}
if !strings.HasPrefix(id, "eipalloc-") {
return errors.New("invalid ElasticIP allocation ID format")
} Try / catch
if err != nil && strings.Contains(err.Error(), "ID must be set, if ElasticIP is shared") {
// add ID to the shared task in the spec, then regenerate terraform
} Prevention
- Always set ID on shared:*true* tasks before terraform-targeted updates
- Look up existing EIP IDs with aws ec2 describe-addresses before switching targets
- Keep shared-resource IDs in version-controlled cluster specs
- Run kops update with --target=terraform in dry form to catch validation early
When it happens
Trigger: A terraform-targeted cluster defines an ElasticIP task with shared: true but no ID — common when converting a cluster to terraform output (`kops update cluster --out --target=terraform`) while relying on auto-allocation.
Common situations: Users switching AWS-target clusters to terraform targets without adding IDs to shared EIP tasks; template cluster specs with shared: true defaults and missing ID overrides.
Related errors
- Subnet ID not set
- os disk is required for VMScaleSet %q
- failed to parse objects: %w
- failed to parse apiVersion %q
- failed to find kind in object
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c4b528d5cf0c21fb.
Report an issue: GitHub.