kubernetes/kops · error

EgressOnlyInternetGateway, InternetGateway, Instance, NatGat

Error message

EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection is required

What it means

This error is raised in Route task CheckChanges when no route target is specified at all. An AWS route must point to exactly one target type (EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection); kOps rejects routes with zero targets before calling AWS.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/route.go:168

			}
		}
		if e.InternetGateway != nil {
			targetCount++
		}
		if e.Instance != nil {
			targetCount++
		}
		if e.NatGateway != nil {
			targetCount++
		}
		if e.TransitGatewayID != nil {
			targetCount++
		}
		if e.VPCPeeringConnectionID != nil {
			targetCount++
		}
		if targetCount == 0 {
			return fmt.Errorf("EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection is required")
		}
		if targetCount != 1 {
			return fmt.Errorf("cannot set more than one EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGateway, or VpcPeeringConnection")
		}
	}

	if a != nil {
		if changes.RouteTable != nil {
			return fi.CannotChangeField("RouteTable")
		}
		if changes.CIDR != nil {
			return fi.CannotChangeField("CIDR")
		}
		if changes.IPv6CIDR != nil {
			return fi.CannotChangeField("IPv6CIDR")
		}
	}
	return nil

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Add the intended target (e.g. internetGateway: igw-123 or natGateway: nat-456) to the route
  2. Check the upstream data source that generated the route to ensure the target field is populated
  3. Validate the manifest with kops before applying

Example fix

// before
route:
  cidr: 0.0.0.0/0
// after
route:
  cidr: 0.0.0.0/0
  internetGateway: igw-0abc123
Defensive patterns

Strategy: validation

Validate before calling

func hasRouteTarget(r Route) bool {
	return r.EgressOnlyInternetGateway != nil || r.InternetGateway != nil ||
		r.Instance != nil || r.NatGateway != nil ||
		r.TransitGatewayID != nil || r.VPCPeeringConnectionID != nil
}
if !hasRouteTarget(route) { return errors.New("route requires exactly one target") }

Prevention

When it happens

Trigger: Defining a Route task with a CIDR/IPv6CIDR destination but leaving all target fields (EgressOnlyInternetGateway, InternetGateway, Instance, NatGateway, TransitGatewayID, VPCPeeringConnectionID) nil.

Common situations: Hand-writing route entries in a cluster manifest and forgetting the target; a templating tool dropping a field; deleting the target stanza during refactor.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5d03a7d310ccc276. Report an issue: GitHub.