{"record":{"id":"c4b528d5cf0c21fb","repo":"kubernetes/kops","slug":"id-must-be-set-if-elasticip-is-shared-v","errorCode":null,"errorMessage":"ID must be set, if ElasticIP is shared: %v","messagePattern":"ID must be set, if ElasticIP is shared: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/elastic_ip.go","lineNumber":284,"sourceCode":"\t\t}\n\t} else {\n\t\t// TODO: Figure out what we can do.  We're sort of stuck between wanting to have one code-path with\n\t\t// terraform, and having a bigger \"window of loss\" here before we create the NATGateway\n\t\tklog.V(2).Infof(\"ElasticIP %q not tagged on subnet; risk of leaking\", fi.ValueOf(publicIp))\n\t}\n\n\treturn nil\n}\n\ntype terraformElasticIP struct {\n\tDomain *string           `cty:\"domain\"`\n\tTags   map[string]string `cty:\"tags\"`\n}\n\nfunc (_ *ElasticIP) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *ElasticIP) error {\n\tif fi.ValueOf(e.Shared) {\n\t\tif e.ID == nil {\n\t\t\treturn fmt.Errorf(\"ID must be set, if ElasticIP is shared: %v\", e)\n\t\t}\n\t\tklog.V(4).Infof(\"reusing existing ElasticIP with id %q\", aws.ToString(e.ID))\n\t\treturn nil\n\t}\n\n\ttf := &terraformElasticIP{\n\t\tDomain: aws.String(\"vpc\"),\n\t\tTags:   e.Tags,\n\t}\n\n\treturn t.RenderResource(\"aws_eip\", *e.Name, tf)\n}\n\nfunc (e *ElasticIP) TerraformLink() *terraformWriter.Literal {\n\tif fi.ValueOf(e.Shared) {\n\t\tif e.ID == nil {\n\t\t\tklog.Fatalf(\"ID must be set, if ElasticIP is shared: %v\", e)\n\t\t}","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/elastic_ip.go#L266-L302","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nelasticIPs:\n- shared: true\n  // ID missing\n// after\nelasticIPs:\n- shared: true\n  id: eipalloc-0abc123def4567890","handlingStrategy":"validation","validationCode":"if fi.ValueOf(shared) && id == nil {\n    return errors.New(\"shared ElasticIP requires an existing eipalloc-* ID\")\n}\nif !strings.HasPrefix(id, \"eipalloc-\") {\n    return errors.New(\"invalid ElasticIP allocation ID format\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"ID must be set, if ElasticIP is shared\") {\n    // add ID to the shared task in the spec, then regenerate terraform\n}","preventionTips":["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"],"tags":["terraform","elastic-ip","validation","shared-resource"],"backgroundTag":"required-field-not-set","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}