kubernetes/kops · error

VPC %q not found

Error message

VPC %q not found

What it means

During cluster-up subnet/CIDR assignment, kOps was asked to look up the VPC with ID `spec.networking.networkID` but `cloud.FindVPCInfo` returned nil — the VPC does not exist (or is not visible to the credentials in use). kOps refuses to proceed because it cannot resolve subnets or CIDRs for a nonexistent network.

Source

Thrown at upup/pkg/fi/cloudup/subnets.go:74

				needZones = true
				break
			}
		}
	}

	if allSubnetsHaveCIDRs(c) && !needZones {
		klog.V(4).Infof("All subnets have CIDRs; skipping assignment logic")
		return nil
	}

	if c.Spec.Networking.NetworkID != "" {

		vpcInfo, err := cloud.FindVPCInfo(c.Spec.Networking.NetworkID)
		if err != nil {
			return err
		}
		if vpcInfo == nil {
			return fmt.Errorf("VPC %q not found", c.Spec.Networking.NetworkID)
		}

		subnetByID := make(map[string]*fi.SubnetInfo)
		for _, subnetInfo := range vpcInfo.Subnets {
			subnetByID[subnetInfo.ID] = subnetInfo
		}
		for i := range c.Spec.Networking.Subnets {
			subnet := &c.Spec.Networking.Subnets[i]
			if subnet.ID != "" {
				cloudSubnet := subnetByID[subnet.ID]
				if cloudSubnet == nil {
					return fmt.Errorf("Subnet %q not found in VPC %q", subnet.ID, c.Spec.Networking.NetworkID)
				}
				if subnet.CIDR == "" {
					subnet.CIDR = cloudSubnet.CIDR
					// IPv6-only private subnets do not have an IPv4 CIDR
					if subnet.CIDR == "" && (subnet.IPv6CIDR == "" || subnet.Type != kops.SubnetTypePrivate) {
						return fmt.Errorf("Subnet %q did not have CIDR", subnet.ID)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the VPC ID exists: `aws ec2 describe-vpcs --vpc-ids vpc-xxxx` in the same region/account as the cluster.
  2. Correct `spec.networking.networkID` (or the `--vpc` flag) in the cluster spec, then `kops update cluster`.
  3. Check the cloud credentials can `ec2:DescribeVpcs` on that VPC (shared VPC requires cross-account access).

Example fix

// before (cluster.yaml)
networking:
  networkID: vpc-0123456789deadbeef  # deleted
// after
networking:
  networkID: vpc-0abcdef1234567890
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command("aws", "ec2", "describe-vpcs", "--vpc-ids", vpcID, "--region", region).Output()
if err != nil { return fmt.Errorf("VPC %s not visible in region %s: %w", vpcID, region, err) }

Prevention

When it happens

Trigger: `kops create cluster --vpc=vpc-xxxx` (or cluster spec networking.networkID) referencing a VPC ID that is wrong, belongs to a different region/account, or the cloud credentials lack permission to describe it.

Common situations: Typo in the VPC ID; using shared-VPC clusters with credentials that cannot see the VPC; VPC deleted after the cluster spec was written; running in the wrong region.

Related errors


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