kubernetes/kops · error

failed to determine VPC id of subnet %s

Error message

failed to determine VPC id of subnet %s

What it means

setupVPC (AWS branch) returns this guard when the described subnet has no VpcId set, so the cluster's network ID cannot be inferred from the given subnet. It fires on an unexpected/empty DescribeSubnets response rather than an API error.

Source

Thrown at upup/pkg/fi/cloudup/new_cluster.go:655

	return featureGate, enabled, nil
}

func setupVPC(opt *NewClusterOptions, cluster *api.Cluster, cloud fi.Cloud) error {
	ctx := context.TODO()
	cluster.Spec.Networking.NetworkID = opt.NetworkID

	switch cluster.GetCloudProvider() {
	case api.CloudProviderAWS:
		if cluster.Spec.Networking.NetworkID == "" && len(opt.SubnetIDs) > 0 {
			awsCloud := cloud.(awsup.AWSCloud)
			res, err := awsCloud.EC2().DescribeSubnets(ctx, &ec2.DescribeSubnetsInput{
				SubnetIds: []string{opt.SubnetIDs[0]},
			})
			if err != nil {
				return fmt.Errorf("error describing subnet %s: %v", opt.SubnetIDs[0], err)
			}
			if len(res.Subnets) == 0 || res.Subnets[0].VpcId == nil {
				return fmt.Errorf("failed to determine VPC id of subnet %s", opt.SubnetIDs[0])
			}
			cluster.Spec.Networking.NetworkID = *res.Subnets[0].VpcId
		}

		if featureflag.Spotinst.Enabled() {
			if opt.SpotinstProduct != "" {
				cluster.Spec.CloudProvider.AWS.SpotinstProduct = new(opt.SpotinstProduct)
			}
			if opt.SpotinstOrientation != "" {
				cluster.Spec.CloudProvider.AWS.SpotinstOrientation = new(opt.SpotinstOrientation)
			}
		}

	case api.CloudProviderGCE:
		if cluster.Spec.CloudConfig == nil {
			cluster.Spec.CloudConfig = &api.CloudConfiguration{}
		}
		cluster.Spec.CloudProvider.GCE.Project = opt.Project

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the subnet ID resolves to a valid subnet in the region
  2. Pass --networkid explicitly instead of inferring from the subnet
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/new_cluster.go:655 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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