{"record":{"id":"1bfbdce91ef886d2","repo":"kubernetes/kops","slug":"found-multiple-elasticips-for-v","errorCode":null,"errorMessage":"found multiple ElasticIPs for: %v","messagePattern":"found multiple ElasticIPs for: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/elastic_ip.go","lineNumber":144,"sourceCode":"\tif publicIP != nil || allocationID != nil {\n\t\trequest := &ec2.DescribeAddressesInput{}\n\t\tif allocationID != nil {\n\t\t\trequest.AllocationIds = []string{fi.ValueOf(allocationID)}\n\t\t} else if publicIP != nil {\n\t\t\trequest.Filters = []ec2types.Filter{awsup.NewEC2Filter(\"public-ip\", *publicIP)}\n\t\t}\n\n\t\tresponse, err := cloud.EC2().DescribeAddresses(ctx, request)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing ElasticIPs: %v\", err)\n\t\t}\n\n\t\tif response == nil || len(response.Addresses) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"found no ElasticIPs for: %v\", e)\n\t\t}\n\n\t\tif len(response.Addresses) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"found multiple ElasticIPs for: %v\", e)\n\t\t}\n\t\ta := response.Addresses[0]\n\t\tactual := &ElasticIP{\n\t\t\tID:       a.AllocationId,\n\t\t\tPublicIP: a.PublicIp,\n\t\t}\n\t\tactual.TagOnSubnet = e.TagOnSubnet\n\t\tactual.AssociatedNatGatewayRouteTable = e.AssociatedNatGatewayRouteTable\n\n\t\t{\n\t\t\ttags, err := cloud.EC2().DescribeTags(ctx, &ec2.DescribeTagsInput{\n\t\t\t\tFilters: []ec2types.Filter{\n\t\t\t\t\t{\n\t\t\t\t\t\tName:   aws.String(\"resource-id\"),\n\t\t\t\t\t\tValues: []string{aws.ToString(a.AllocationId)},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t})","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/elastic_ip.go#L126-L162","documentation":"find() requires DescribeAddresses to return exactly one address for the allocation ID or public-ip filter. If more than one address matches (e.g. the public-ip filter matches several addresses across accounts/regions is impossible, but can occur with permissive filters or duplicated state), it throws 'found multiple ElasticIPs for: %v' because kOps cannot unambiguously map AWS state onto the single task.","triggerScenarios":"len(response.Addresses) > 1 after DescribeAddresses with a public-ip filter returning multiple matches — practically caused by duplicated spec entries with the same PublicIP, or by a filter that isn't unique (e.g. a public-ip value reused via VPC sharing / multiple accounts aggregated in a management role).","commonSituations":"Cross-account aggregated resource views via AWS Organizations and a shared management IAM role; copy-pasted identical PublicIP values across different cluster task definitions; resource share (IPAM pool) returning multiple matching addresses.","solutions":["Ensure each ElasticIP task in the spec has a unique PublicIP; use the allocation ID (eipalloc-*) instead of public IP for unambiguous lookup","Check for duplicate ElasticIP task definitions in `kops get cluster -oyaml`","Verify the IAM credentials resolve to the intended single account (aws sts get-caller-identity)","If an IPAM resource share is aggregating addresses, scope the lookup or use explicit AllocationIds"],"exampleFix":"// before: ambiguous lookup by public IP\nPublicIP: fi.String(\"52.1.2.3\")\n// after: pin to exact allocation\nID: fi.String(\"eipalloc-0abc123def4567890\")","handlingStrategy":"type-guard","validationCode":"func uniqueAddresses(addrs []ec2types.Address) bool { return len(addrs) <= 1 }\n// call DescribeAddresses and assert uniqueness before reconciling","typeGuard":"func singleMatch(rs []ec2types.Address) (*ec2types.Address, bool) {\n    if len(rs) != 1 { return nil, false }\n    return &rs[0], true\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"found multiple ElasticIPs\") {\n    // fall back to exact AllocationIds lookup instead of public-ip filter\n}","preventionTips":["Prefer allocation ID over public IP in specs","Ensure one AWS account/credential chain is in use (no Organizations aggregation surprises)","Keep PublicIP values unique across tasks","Audit specs for duplicate ElasticIP definitions"],"tags":["aws","ec2","elastic-ip","ambiguous-state"],"backgroundTag":"ambiguous-resource-lookup","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"}