kubernetes/kops · error

VPC %q not found

Error message

VPC %q not found

What it means

FindVPCInfo returns (nil, nil) when the given VPC ID does not exist in the account/region — the API succeeds but nothing is found. kOps distinguishes this from an API failure and returns a dedicated "VPC %q not found" error so the user knows the VPC ID itself is wrong rather than the call failing.

Source

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

		}
	}

	return zoneToSubnetsMap, nil
}

func getAWSZoneToSubnetProviderID(VPCID string, region string, subnetIDs []string) (map[string]string, error) {
	res := make(map[string]string)
	cloudTags := map[string]string{}
	awsCloud, err := awsup.NewAWSCloud(region, cloudTags)
	if err != nil {
		return res, fmt.Errorf("error loading cloud: %v", err)
	}
	vpcInfo, err := awsCloud.FindVPCInfo(VPCID)
	if err != nil {
		return res, fmt.Errorf("error describing VPC: %v", err)
	}
	if vpcInfo == nil {
		return res, fmt.Errorf("VPC %q not found", VPCID)
	}
	subnetByID := make(map[string]*fi.SubnetInfo)
	for _, subnetInfo := range vpcInfo.Subnets {
		subnetByID[subnetInfo.ID] = subnetInfo
	}
	for _, subnetID := range subnetIDs {
		subnet, ok := subnetByID[subnetID]
		if !ok {
			return res, fmt.Errorf("subnet %s not found in VPC %s", subnetID, VPCID)
		}
		if res[subnet.Zone] != "" {
			return res, fmt.Errorf("subnet %s and %s have the same zone", subnetID, res[subnet.Zone])
		}
		res[subnet.Zone] = subnetID
	}
	return res, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the VPC ID with `aws ec2 describe-vpcs --vpc-ids vpc-xxx --region <region>` using the same credentials/region.
  2. Correct the --vpc flag; ensure the region matches the VPC's region.
  3. For shared VPCs, run kOps with credentials of an account that can describe the VPC, or confirm RAM sharing.
  4. Check whether the VPC was deleted and pick a new one.

Example fix

// before
--vpc vpc-0olddeleted --region eu-west-1
// after
--vpc vpc-0correctid --region eu-west-1  # confirmed via aws ec2 describe-vpcs
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

if strings.Contains(err.Error(), "VPC \"vpc-") && strings.Contains(err.Error(), "not found") {
    // prompt user to re-check --vpc ID, account, and region before retry
}

Prevention

When it happens

Trigger: `kops create cluster --cloud aws --vpc vpc-0abc... --subnets subnet-...` where the VPC ID is mistyped, belongs to another region/account, was deleted, or comes from a shared-VPC account the caller cannot see.

Common situations: Copy-pasting a VPC ID from the wrong region console; typos like vpc-012345 vs vpc-543210; shared VPC visible only from the host account; VPC deleted between writing the script and running it.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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