{"record":{"id":"47021ea46c56ea46","repo":"kubernetes/kops","slug":"cannot-set-more-than-one-egressonlyinternetgateway","errorCode":null,"errorMessage":"cannot set more than one EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection","messagePattern":"cannot set more than one EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/route.go","lineNumber":171,"sourceCode":"\t\t\ttargetCount++\n\t\t}\n\t\tif e.Instance != nil {\n\t\t\ttargetCount++\n\t\t}\n\t\tif e.NatGateway != nil {\n\t\t\ttargetCount++\n\t\t}\n\t\tif e.TransitGatewayID != nil {\n\t\t\ttargetCount++\n\t\t}\n\t\tif e.VPCPeeringConnectionID != nil {\n\t\t\ttargetCount++\n\t\t}\n\t\tif targetCount == 0 {\n\t\t\treturn fmt.Errorf(\"EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection is required\")\n\t\t}\n\t\tif targetCount != 1 {\n\t\t\treturn fmt.Errorf(\"cannot set more than one EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection\")\n\t\t}\n\t}\n\n\tif a != nil {\n\t\tif changes.RouteTable != nil {\n\t\t\treturn fi.CannotChangeField(\"RouteTable\")\n\t\t}\n\t\tif changes.CIDR != nil {\n\t\t\treturn fi.CannotChangeField(\"CIDR\")\n\t\t}\n\t\tif changes.IPv6CIDR != nil {\n\t\t\treturn fi.CannotChangeField(\"IPv6CIDR\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (_ *Route) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Route) error {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/route.go#L153-L189","documentation":"This error is raised in Route task CheckChanges when more than one route target is specified. AWS routes allow exactly one target per route, so kOps counts the populated target fields (EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, VPCPeeringConnection) and rejects any count above one.","triggerScenarios":"Setting two or more of the target fields on the same Route task, e.g. both internetGateway and natGateway.","commonSituations":"Merging route definitions from two sources; copy-paste errors adding a second target; misunderstanding that fallback/multiple targets are supported.","solutions":["Keep only one target field and remove the others","Split traffic across separate routes with distinct destination CIDRs if multiple paths are genuinely needed","Regenerate the manifest to clear conflicting fields"],"exampleFix":"// before\nroute:\n  cidr: 0.0.0.0/0\n  internetGateway: igw-1\n  natGateway: nat-1\n// after\nroute:\n  cidr: 0.0.0.0/0\n  internetGateway: igw-1","handlingStrategy":"validation","validationCode":"func targetCount(r Route) int {\n\tn := 0\n\tfor _, t := range []*string{r.EgressOnlyInternetGatewayID, r.InternetGatewayID, r.InstanceID, r.NatGatewayID, r.TransitGatewayID, r.VPCPeeringConnectionID} {\n\t\tif t != nil { n++ }\n\t}\n\treturn n\n}\nif targetCount(route) > 1 { return errors.New(\"route allows at most one target\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce exactly-one-target in any manifest generator you build","Avoid merging route stanzas from multiple sources without conflict detection"],"tags":["aws","route","validation","multiple-targets"],"backgroundTag":"mutually-exclusive-fields","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}