kubernetes/kops · error

error listing Instances: %v

Error message

error listing Instances: %v

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:1638

	for k, v := range merged {
		filter := NewEC2Filter("tag:"+k, v)
		filters = append(filters, filter)
	}
	return filters
}

// DescribeInstance is a helper that queries for the specified instance by id
func (c *awsCloudImplementation) DescribeInstance(instanceID string) (*ec2types.Instance, error) {
	klog.V(2).Infof("Calling DescribeInstances for instance %q", instanceID)
	ctx := context.TODO()
	request := &ec2.DescribeInstancesInput{
		InstanceIds: []string{instanceID},
	}

	response, err := c.EC2().DescribeInstances(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("error listing Instances: %v", err)
	}
	if response == nil || len(response.Reservations) == 0 {
		return nil, nil
	}
	if len(response.Reservations) != 1 {
		klog.Fatalf("found multiple Reservations for %q", instanceID)
	}

	reservation := response.Reservations[0]
	if len(reservation.Instances) == 0 {
		return nil, nil
	}

	if len(reservation.Instances) != 1 {
		return nil, fmt.Errorf("found multiple Instances for %q", instanceID)
	}

	instance := reservation.Instances[0]

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the instance ID exists with `aws ec2 describe-instances --instance-ids <id>` in the configured region.
  2. If terminated, refresh kops cluster state or recreate the instance/instance group.
  3. Check IAM ec2:DescribeInstances permission.
  4. Retry if the error is throttling/transient.
Defensive patterns

Strategy: fallback

Validate before calling

// Check instance existence/region before DescribeInstances
_, err := ec2Client.DescribeInstances(ctx, &ec2.DescribeInstancesInput{InstanceIds: []string{instanceID}})
// if InvalidInstanceID.NotFound => treat as missing, not fatal

Try / catch

inst, err := c.DescribeInstance(instanceID)
if err != nil {
    var nf smithy.APIError
    if errors.As(err, &nf) && nf.ErrorCode() == "InvalidInstanceID.NotFound" {
        return nil, nil // instance terminated; treat as absent
    }
    return nil, err
}

Prevention

When it happens

Trigger: DescribeInstances with an instanceID that does not exist (terminated instance), wrong region, IAM missing ec2:DescribeInstances, or throttling under load.

Common situations: Instance terminated between discovery and validation; cluster state referencing an instance from a deleted VPC; region misconfiguration; autoscaling replaced the instance.

Related errors


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