{"record":{"id":"d64e9f36c4df3cbd","repo":"kubernetes/kops","slug":"error-checking-if-instance-type-q-is-supported-in","errorCode":null,"errorMessage":"error checking if instance type %q is supported in region %q: %v","messagePattern":"error checking if instance type %q is supported in region %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":2060,"sourceCode":"}\n\n// supportsInstanceType uses the DescribeReservedInstancesOfferings API call to determine if an instance type is supported in a region\nfunc (c *awsCloudImplementation) zonesWithInstanceType(instanceType ec2types.InstanceType) (sets.String, error) {\n\tklog.V(4).Infof(\"checking if instance type %q is supported in region %q\", instanceType, c.region)\n\tctx := context.TODO()\n\trequest := &ec2.DescribeReservedInstancesOfferingsInput{}\n\trequest.InstanceTenancy = ec2types.TenancyDefault\n\trequest.IncludeMarketplace = aws.Bool(false)\n\trequest.OfferingClass = ec2types.OfferingClassTypeStandard\n\trequest.OfferingType = ec2types.OfferingTypeValuesNoUpfront\n\trequest.ProductDescription = ec2types.RIProductDescriptionLinuxUnixAmazonVpc\n\trequest.InstanceType = instanceType\n\n\tzones := sets.NewString()\n\n\tresponse, err := c.ec2.DescribeReservedInstancesOfferings(ctx, request)\n\tif err != nil {\n\t\treturn zones, fmt.Errorf(\"error checking if instance type %q is supported in region %q: %v\", instanceType, c.region, err)\n\t}\n\n\tfor _, item := range response.ReservedInstancesOfferings {\n\t\tif item.InstanceType == instanceType {\n\t\t\tzones.Insert(aws.ToString(item.AvailabilityZone))\n\t\t} else {\n\t\t\tklog.Warningf(\"skipping non-matching instance type offering: %v\", item)\n\t\t}\n\t}\n\n\treturn zones, nil\n}\n\n// DescribeInstanceType calls ec2.DescribeInstanceType to get information for a particular instance type\nfunc (c *awsCloudImplementation) DescribeInstanceType(instanceType string) (*ec2types.InstanceTypeInfo, error) {\n\tif info, ok := c.instanceTypes.typeMap[instanceType]; ok {\n\t\treturn info, nil\n\t}","sourceCodeStart":2042,"sourceCodeEnd":2078,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L2042-L2078","documentation":"zonesWithInstanceType calls EC2 DescribeReservedInstancesOfferings to determine which availability zones support a given instance type. If that AWS API call fails, the error is wrapped with the instance type and region. It reports an AWS API failure during instance-type support probing, not a conclusion about the type itself.","triggerScenarios":"c.ec2.DescribeReservedInstancesOfferings(ctx, request) returns an error — AuthFailure/UnauthorizedOperation (missing ec2:DescribeReservedInstancesOfferings), throttling, InvalidParameterValue (malformed instance type), or network/endpoint failure.","commonSituations":"Read-only IAM policies missing EC2 reserved-instances describe permission; AWS throttling on accounts with heavy API usage; corporate proxy/firewall blocking EC2 endpoints; passing an instance-type string not valid for EC2.","solutions":["Inspect the wrapped %v cause to identify the AWS error code (auth vs throttling vs invalid parameter).","Grant the credentials ec2:DescribeReservedInstancesOfferings permission.","If throttled, add exponential backoff around the call and retry.","Verify the instance type string is a valid EC2 type for that region.","Check network connectivity to the regional EC2 endpoint (VPC endpoints/proxy/DNS)."],"exampleFix":"// before: single attempt\nresponse, err := c.ec2.DescribeReservedInstancesOfferings(ctx, request)\nif err != nil { return zones, fmt.Errorf(...) }\n// after: tolerate API failure instead of failing provisioning\nresponse, err := c.ec2.DescribeReservedInstancesOfferings(ctx, request)\nif err != nil {\n    klog.Warningf(\"DescribeReservedInstancesOfferings failed for %s: %v; assuming all zones\", instanceType, err)\n    return nil, nil\n}","handlingStrategy":"try-catch","validationCode":"// verify EC2 permissions and connectivity first\naws ec2 describe-reserved-instances-offerings --region <region> --max-results 1","typeGuard":null,"tryCatchPattern":"zones, err := c.zonesWithInstanceType(instanceType)\nif err != nil {\n    klog.Warningf(\"instance-type probe failed (%v); defaulting to all configured zones\", err)\n    zones = sets.NewString(clusterZones...)\n}","preventionTips":["Grant ec2:DescribeReservedInstancesOfferings in the kops IAM policy.","Add SDK retry configuration for transient EC2 errors.","Validate instance-type strings against the region's supported list before probing.","Monitor AWS API throttling metrics and space out provisioning operations."],"tags":["aws","ec2","api-error","iam","instance-type"],"backgroundTag":"aws-api-call-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}