AmazonCloudFormationClient amazonCFClient = awsStackUtil.createCloudFormationClient(awsTemplate.getRegion(), awsCredential);
return getInstanceIds(stack, amazonASClient, amazonCFClient);
}
public List<String> getInstanceIds(Stack stack, AmazonAutoScalingClient amazonASClient, AmazonCloudFormationClient amazonCFClient) {
DescribeAutoScalingGroupsResult describeAutoScalingGroupsResult = amazonASClient
.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(getAutoscalingGroupName(stack, amazonCFClient)));
List<String> instanceIds = new ArrayList<>();
if (describeAutoScalingGroupsResult.getAutoScalingGroups().get(0).getInstances() != null) {
for (Instance instance : describeAutoScalingGroupsResult.getAutoScalingGroups().get(0).getInstances()) {
instanceIds.add(instance.getInstanceId());
}
}
return instanceIds;
}