kubernetes/kops · error
Region is not a recognized EC2 region: %q (check you have sp
Error message
Region is not a recognized EC2 region: %q (check you have specified valid zones?)
What it means
After querying EC2 for all valid regions, ValidateRegion checks whether the requested region name appears in that list. If it does not — and SKIP_REGION_CHECK is not set — the library rejects the region as not a recognized EC2 region and suggests checking the specified zones. This guards against typos in region names that would otherwise produce confusing failures later during cluster creation.
Source
Thrown at upup/pkg/fi/cloudup/awsup/aws_utils.go:88
if err != nil {
return fmt.Errorf("got an error while querying for valid regions (verify your AWS credentials?): %v", err)
}
allRegions = response.Regions
}
for _, r := range allRegions {
name := aws.ToString(r.RegionName)
if name == region {
return nil
}
}
if os.Getenv("SKIP_REGION_CHECK") != "" {
klog.Infof("AWS region does not appear to be valid, but skipping because SKIP_REGION_CHECK is set")
return nil
}
return fmt.Errorf("Region is not a recognized EC2 region: %q (check you have specified valid zones?)", region)
}
// FindRegion determines the region from the zones specified in the cluster
func FindRegion(cluster *kops.Cluster) (string, error) {
region := ""
for _, subnet := range cluster.Spec.Networking.Subnets {
if subnet.Zone == "" {
// The zone of a subnet specified by ID is looked up from the cloud later.
if subnet.ID == "" {
return "", fmt.Errorf("subnet %q must specify a zone or the ID of an existing subnet", subnet.Name)
}
continue
}
if len(subnet.Zone) <= 2 {
return "", fmt.Errorf("invalid AWS zone: %q in subnet %q", subnet.Zone, subnet.Name)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Correct the region name in the cluster spec / --zone flags to a valid EC2 region (e.g. us-east-1, eu-west-1)
- Set SKIP_REGION_CHECK=1 only as a deliberate override when you know the region is valid but EC2 cannot be queried
- Verify the region belongs to the partition your credentials support
Example fix
// before zones: ["us-east1a"] // after zones: ["us-east-1a"]
Defensive patterns
Strategy: validation
Validate before calling
var regionRe = regexp.MustCompile(`^(us|eu|ap|ca|sa|af|me|il)-[a-z]+-\d$|^cn-north(-\d+)?$|^us-gov-[a-z]+-\d$`)
func regionLooksValid(region string) bool { return regionRe.MatchString(region) } Try / catch
if err := kopsValidateRegion(ctx, region); err != nil {
if strings.Contains(err.Error(), "not a recognized EC2 region") {
log.Fatalf("typo in region %q? check zones flags", region)
}
return err
} Prevention
- Validate region names against the output of `aws ec2 describe-regions` in CI
- Derive the region from zone names programmatically rather than hardcoding
- Use SKIP_REGION_CHECK=1 only deliberately, never to silence typos
When it happens
Trigger: Calling ValidateRegion (via BuildCloud) with a region string that is not in the DescribeRegions response — misspelled region, wrong partition (e.g. us-gov-west-1 with standard credentials), or an empty/garbage value derived from zones.
Common situations: Typo like 'us-east1' or 'eu-west' in kops cluster spec; using a China/GovCloud region with the wrong account; SKIP_REGION_CHECK unset in offline/air-gapped environments where DescribeRegions response was unusable.
Related errors
- VPC ID is required when InternetGateway is shared
- AWS partition was empty
- invalid GCE Zone: %v
- --region is required (when --external)
- failed to load default aws config for IMDS client: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/eadb801227a3c4ea.
Report an issue: GitHub.