<br>
Needed AWS actions:
<ul>
<li>autoscaling:DescribeAutoScalingInstances</li>
</ul>

@return the name of the auto scaling group the current instance is a member of
18899
public String getAutoScalingGroup() {
        DescribeAutoScalingInstancesRequest req = new DescribeAutoScalingInstancesRequest();
        req.setInstanceIds(Collections.singleton(this.getInstanceId()));
        DescribeAutoScalingInstancesResult result = this.autoScalingClient.describeAutoScalingInstances(req);
        if (result.getAutoScalingInstances().size() != 1) {
            throw new IllegalStateException("Found multiple auto scaling instances");
        }
        return result.getAutoScalingInstances().get(0).getAutoScalingGroupName();
    }
1075096
public Cloud resize() throws Exception {

    AmazonEC2Client ec2 = new AmazonEC2Client(new PersistS3.H2OAWSCredentialsProviderChain());
    ec2.setEndpoint("ec2." + region + ".amazonaws.com");
    DescribeInstancesResult describeInstancesResult = ec2.describeInstances();
    List<Reservation> reservations = describeInstancesResult.getReservations();
    List<Instance> instances = new ArrayList<Instance>();

    for( Reservation reservation : reservations ) {
      for( Instance instance : reservation.getInstances() ) {
        String ip = ip(instance);
        if( ip != null ) {
          String name = null;
          if( instance.getTags().size() > 0 )
            name = instance.getTags().get(0).getValue();
          if( NAME.equals(name) )
            instances.add(instance);
        }
      }
    }
    System.out.println("Found " + instances.size() + " EC2 instances for user " + USER);

    if( instances.size() > boxes ) {
      for( int i = 0; i < instances.size() - boxes; i++ ) {
        // TODO terminate?
      }
    } else if( instances.size() < boxes ) {
      int launchCount = boxes - instances.size();
      System.out.println("Creating " + launchCount + " EC2 instances.");
      if( confirm ) {
        System.out.println("Please confirm [y/n]");
        String s = Utils.readConsole();
        if( s == null || !s.equalsIgnoreCase("y") )
          throw new Exception("Aborted");
      }

      CreatePlacementGroupRequest group = new CreatePlacementGroupRequest();
      group.withGroupName(USER);
      group.withStrategy(PlacementStrategy.Cluster);
      try {
        ec2.createPlacementGroup(group);
      } catch( AmazonServiceException ex ) {
        if( !"InvalidPlacementGroup.Duplicate".equals(ex.getErrorCode()) )
          throw ex;
      }

      RunInstancesRequest run = new RunInstancesRequest();
      run.withInstanceType(type);
      run.withImageId(image);
      run.withMinCount(launchCount).withMaxCount(launchCount);
      run.withSecurityGroupIds(securityGroup);
      Placement placement = new Placement();
      placement.setGroupName(USER);
      run.withPlacement(placement);
      BlockDeviceMapping map = new BlockDeviceMapping();
      map.setDeviceName("/dev/sdb");
      map.setVirtualName("ephemeral0");
      run.withBlockDeviceMappings(map);
      run.withUserData(new String(Base64.encodeBase64(cloudConfig.getBytes())));

      RunInstancesResult runRes = ec2.runInstances(run);
      ArrayList<String> ids = new ArrayList<String>();
      for( Instance instance : runRes.getReservation().getInstances() )
        ids.add(instance.getInstanceId());

      List<Instance> created = wait(ec2, ids);
      System.out.println("Created " + created.size() + " EC2 instances.");
      instances.addAll(created);
    }

    String[] pub = new String[boxes];
    String[] prv = new String[boxes];
    for( int i = 0; i < boxes; i++ ) {
      pub[i] = instances.get(i).getPublicIpAddress();
      prv[i] = instances.get(i).getPrivateIpAddress();
    }
    System.out.println("EC2 public IPs: " + Utils.join(' ', pub));
    System.out.println("EC2 private IPs: " + Utils.join(' ', prv));
    Cloud cloud = new Cloud();
    cloud.publicIPs.addAll(Arrays.asList(pub));
    cloud.privateIPs.addAll(Arrays.asList(prv));
    return cloud;
  }
1364705
public java.util.List<String> getInstanceGroupTypes() {
        if (instanceGroupTypes == null) {
            instanceGroupTypes = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return instanceGroupTypes;
    }
205897
public java.util.List<ScalingPolicy> getScalingPolicies() {
        if (scalingPolicies == null) {
            scalingPolicies = new com.amazonaws.internal.SdkInternalList<ScalingPolicy>();
        }
        return scalingPolicies;
    }
670173
public Integer getScale()
   {
      if(childNode.getAttribute("scale") != null && !childNode.getAttribute("scale").equals("null"))
      {
         return Integer.valueOf(childNode.getAttribute("scale"));
      }
      return null;
   }
1354545
public java.util.List<AutoScalingInstanceDetails> getAutoScalingInstances() {
        if (autoScalingInstances == null) {
            autoScalingInstances = new com.amazonaws.internal.SdkInternalList<AutoScalingInstanceDetails>();
        }
        return autoScalingInstances;
    }
83922
def do_asg(self,args):
        """"""
        parser = CommandArgumentParser("asg")
        parser.add_argument(dest='asg',help='asg index or name');
        args = vars(parser.parse_args(args))

        print "loading auto scaling group {}".format(args['asg'])
        try:
            index = int(args['asg'])
            asgSummary = self.wrappedStack['resourcesByTypeIndex']['AWS::AutoScaling::AutoScalingGroup'][index]
        except:
            asgSummary = self.wrappedStack['resourcesByTypeName']['AWS::AutoScaling::AutoScalingGroup'][args['asg']]

        self.stackResource(asgSummary.stack_name,asgSummary.logical_id)
591490
public Instance getInstance() {
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        req.setInstanceIds(Collections.singleton(this.getInstanceId()));
        DescribeInstancesResult result = this.ec2Client.describeInstances(req);
        if (result.getReservations().size() != 1) {
            throw new IllegalStateException("Found multiple instances");
        }
        List<Instance> instances = result.getReservations().get(0).getInstances();
        if (instances.size() != 1) {
            throw new IllegalStateException("Found multiple instances");
        }
        return instances.get(0);
    }
1181844
def instance_group(group_name)
      config = config_for_group(group_name)

      instance_group = Elasticity::InstanceGroup.new
      instance_group.role = group_name.upcase
      instance_group.type = config['instance_type']

      if config.has_key?('instance_count') && config['instance_count'] > 0
        instance_group.count = config['instance_count']
      end

      if config['use_spot_instances'] == true
        instance_group.set_spot_instances(config['bid_price'])
      end

      instance_group
    end
63547
protected function autoScale()
    {
        $this->lastAutoScaled = $this->lastAutoScaled ?:
                    Chronos::now()->subSeconds($this->autoScaleCooldown + 1);

        if (Chronos::now()->subSeconds($this->autoScaleCooldown)->gte($this->lastAutoScaled)) {
            $this->lastAutoScaled = Chronos::now();

            app(AutoScaler::class)->scale($this);
        }
    }
848830
public static List<Instance> describeAllInstances() {
        // pass any credentials as aws-mock does not authenticate them at all
        AWSCredentials credentials = new BasicAWSCredentials("foo", "bar");
        AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials);

        // the mock endpoint for ec2 which runs on your computer
        String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/";
        amazonEC2Client.setEndpoint(ec2Endpoint);

        DescribeInstancesResult response = amazonEC2Client.describeInstances();
        List<Reservation> reservations = response.getReservations();

        List<Instance> ret = new ArrayList<Instance>();

        for (Reservation reservation : reservations) {
            List<Instance> instances = reservation.getInstances();

            if (null != instances) {

                for (Instance i : instances) {
                    ret.add(i);
                }
            }
        }

        return ret;
    }
790432
def exists(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    retries = 30
    while True:
        try:
            _conn = conn.get_all_groups(names=[name])
            if _conn:
                return True
            else:
                msg = 'The autoscale group does not exist in region {0}'.format(region)
                log.debug(msg)
                return False
        except boto.exception.BotoServerError as e:
            if retries and e.code == 'Throttling':
                log.debug('Throttled by AWS API, retrying in 5 seconds...')
                time.sleep(5)
                retries -= 1
                continue
            log.error(e)
            return False
1070365
func (s *SetInstanceProtectionInput) SetAutoScalingGroupName(v string) *SetInstanceProtectionInput {
	s.AutoScalingGroupName = &v
	return s
}
863320
public java.util.List<LoadBasedAutoScalingConfiguration> getLoadBasedAutoScalingConfigurations() {
        if (loadBasedAutoScalingConfigurations == null) {
            loadBasedAutoScalingConfigurations = new com.amazonaws.internal.SdkInternalList<LoadBasedAutoScalingConfiguration>();
        }
        return loadBasedAutoScalingConfigurations;
    }
1131450
public java.util.List<ClusterParameterGroup> getParameterGroups() {
        if (parameterGroups == null) {
            parameterGroups = new com.amazonaws.internal.SdkInternalList<ClusterParameterGroup>();
        }
        return parameterGroups;
    }
1099064
def _generate_autoscaling_metadata(self, cls, args):
        
        assert isinstance(args, Mapping)
        init_config = self._create_instance(
            cloudformation.InitConfig,
            args['AWS::CloudFormation::Init']['config'])
        init = self._create_instance(
            cloudformation.Init, {'config': init_config})
        auth = None
        if 'AWS::CloudFormation::Authentication' in args:
            auth_blocks = {}
            for k in args['AWS::CloudFormation::Authentication']:
                auth_blocks[k] = self._create_instance(
                    cloudformation.AuthenticationBlock,
                    args['AWS::CloudFormation::Authentication'][k],
                    k)
            auth = self._create_instance(
                cloudformation.Authentication, auth_blocks)

        return cls(init, auth)
1162430
public List<String> getPrivateAutoScalingMemberIPs(String autoScalingGroupName) {
        Preconditions.checkArgument(autoScalingGroupName != null && !autoScalingGroupName.isEmpty());
        List<String> members = this.getAutoScalingMembers(autoScalingGroupName);
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        req.setInstanceIds(members);
        DescribeInstancesResult result = this.ec2Client.describeInstances(req);
        List<String> list = new ArrayList<>();
        for (Reservation reservation : result.getReservations()) {
            for (Instance instance : reservation.getInstances()) {
                if (instance.getState().getName().equals("running")) {
                    list.add(instance.getPrivateIpAddress());
                }
            }
        }
        return list;
    }