AmazonAutoScalingClient asgClient = asgClient();
DescribeAutoScalingInstancesRequest request = new DescribeAutoScalingInstancesRequest();
if (instanceIds != null) {
request.setInstanceIds(Arrays.asList(instanceIds));
}
DescribeAutoScalingInstancesResult result = asgClient.describeAutoScalingInstances(request);
instances.addAll(result.getAutoScalingInstances());
while (result.getNextToken() != null) {
request = request.withNextToken(result.getNextToken());
result = asgClient.describeAutoScalingInstances(request);
instances.addAll(result.getAutoScalingInstances());
}
LOGGER.info(String.format("Got %d auto-scaling instances.", instances.size()));
return instances;
}