{"record":{"id":"cf8224ba0ddd8636","repo":"kubernetes/kops","slug":"error-listing-instances-v-cf8224","errorCode":null,"errorMessage":"error listing Instances: %v","messagePattern":"error listing Instances: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":1638,"sourceCode":"\n\tfor k, v := range merged {\n\t\tfilter := NewEC2Filter(\"tag:\"+k, v)\n\t\tfilters = append(filters, filter)\n\t}\n\treturn filters\n}\n\n// DescribeInstance is a helper that queries for the specified instance by id\nfunc (c *awsCloudImplementation) DescribeInstance(instanceID string) (*ec2types.Instance, error) {\n\tklog.V(2).Infof(\"Calling DescribeInstances for instance %q\", instanceID)\n\tctx := context.TODO()\n\trequest := &ec2.DescribeInstancesInput{\n\t\tInstanceIds: []string{instanceID},\n\t}\n\n\tresponse, err := c.EC2().DescribeInstances(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing Instances: %v\", err)\n\t}\n\tif response == nil || len(response.Reservations) == 0 {\n\t\treturn nil, nil\n\t}\n\tif len(response.Reservations) != 1 {\n\t\tklog.Fatalf(\"found multiple Reservations for %q\", instanceID)\n\t}\n\n\treservation := response.Reservations[0]\n\tif len(reservation.Instances) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(reservation.Instances) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple Instances for %q\", instanceID)\n\t}\n\n\tinstance := reservation.Instances[0]","sourceCodeStart":1620,"sourceCodeEnd":1656,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L1620-L1656","documentation":"Returned when EC2 DescribeInstances fails while fetching a single instance by ID in DescribeInstance. The wrapped AWS error (e.g. InvalidInstanceID.NotFound, AuthFailure, Throttling) is included in the message.","triggerScenarios":"DescribeInstances with an instanceID that does not exist (terminated instance), wrong region, IAM missing ec2:DescribeInstances, or throttling under load.","commonSituations":"Instance terminated between discovery and validation; cluster state referencing an instance from a deleted VPC; region misconfiguration; autoscaling replaced the instance.","solutions":["Verify the instance ID exists with `aws ec2 describe-instances --instance-ids <id>` in the configured region.","If terminated, refresh kops cluster state or recreate the instance/instance group.","Check IAM ec2:DescribeInstances permission.","Retry if the error is throttling/transient."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Check instance existence/region before DescribeInstances\n_, err := ec2Client.DescribeInstances(ctx, &ec2.DescribeInstancesInput{InstanceIds: []string{instanceID}})\n// if InvalidInstanceID.NotFound => treat as missing, not fatal","typeGuard":null,"tryCatchPattern":"inst, err := c.DescribeInstance(instanceID)\nif err != nil {\n    var nf smithy.APIError\n    if errors.As(err, &nf) && nf.ErrorCode() == \"InvalidInstanceID.NotFound\" {\n        return nil, nil // instance terminated; treat as absent\n    }\n    return nil, err\n}","preventionTips":["Refresh instance references from ASG/describe before use","Configure the correct region on the AWSCloud client","Grant ec2:DescribeInstances in IAM","Handle terminated instances gracefully in reconciliation loops"],"tags":["aws","ec2","instances","describe-instances"],"backgroundTag":"aws-api-error","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}