code: public List<Instance> getInstancesForGroup(String groupName,
        String status) {
  
      final AmazonEC2 amazonEC2 = getEc2Client();
  
      final DescribeInstancesResult instancesResult = amazonEC2.describeInstances(new DescribeInstancesRequest()
          .withFilters(new Filter().withName("tag:aws:autoscaling:groupName").withValues(groupName)));
  
      final List<Instance> instances = new ArrayList<>();
      for (Reservation reservation : instancesResult.getReservations()) {
        for (Instance instance : reservation.getInstances()) {
          if (null == status|| null == instance.getState()
              || status.equals(instance.getState().getName())) {
            instances.add(instance);
            LOGGER.info("Found instance: " + instance + " which qualified filter: " + status);
          } else {
            LOGGER.info("Found instance: " + instance + " but did not qualify for filter: " + status);
          }
        }
      }
  
      return instances;
    }
docs: *
  Get list of EC2 {@link Instance}s for a auto scaling group
  
  @param groupName Auto scaling group name
  @param status Instance status (eg. running)
  @return List of EC2 instances found for the input auto scaling group