}
List<AutoScalingGroup> asgs = new LinkedList<AutoScalingGroup>();
AmazonAutoScalingClient asgClient = asgClient();
DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest();
if (names != null) {
request.setAutoScalingGroupNames(Arrays.asList(names));
}
DescribeAutoScalingGroupsResult result = asgClient.describeAutoScalingGroups(request);
asgs.addAll(result.getAutoScalingGroups());
while (result.getNextToken() != null) {
request.setNextToken(result.getNextToken());
result = asgClient.describeAutoScalingGroups(request);
asgs.addAll(result.getAutoScalingGroups());
}
LOGGER.info(String.format("Got %d auto-scaling groups in region %s.", asgs.size(), region));