<br>
Needed AWS actions:
<ul>
<li>ec2:DescribeInstances</li>
</ul>

@return the tags of the current instance
506155
public Map<String, String> getInstanceTags() {
        Map<String, String> map = new HashMap<>();
        Instance instance = this.getInstance();
        for (Tag tag : instance.getTags()) {
            map.put(tag.getKey(), tag.getValue());
        }
        return map;
    }
1121625
private DescribeTagsResponseType describeTags() {
        DescribeTagsResponseType ret = new DescribeTagsResponseType();
        ret.setRequestId(UUID.randomUUID().toString());

        TagSetType tagsSet = new TagSetType();
        for (MockTags mockVpc : mockTagsController.describeTags()) {

            for (String resourceId : mockVpc.getResourcesSet()) {
                TagSetItemType tagItem = new TagSetItemType();
                tagItem.setResourceId(resourceId);
                tagItem.setKey(mockVpc.getTagSet().keySet()
                        .toArray(new String[mockVpc.getTagSet().size()])[0]);
                tagItem.setValue(mockVpc.getTagSet().values()
                        .toArray(new String[mockVpc.getTagSet().size()])[0]);
                tagsSet.getItem().add(tagItem);
            }
        }

        ret.setTagSet(tagsSet);

        return ret;
    }
1370187
def count_by_tag(stack, descriptor):
    
    ec2_conn = boto.ec2.connection.EC2Connection()
    resses = ec2_conn.get_all_instances(
                    filters={
                        'tag:stack': stack,
                        'tag:descriptor': descriptor
                    })
    instance_list_raw = list()
    [[instance_list_raw.append(x) for x in res.instances] for res in resses]
    instance_list = [x for x in instance_list_raw if state_filter(x)]
    instances = len(instance_list)
    return instances
904672
public java.util.List<String> getEc2InstanceIds() {
        if (ec2InstanceIds == null) {
            ec2InstanceIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return ec2InstanceIds;
    }
931185
def readInstanceTag(instanceID, tagName="Name", connection=None):
  
  assert isinstance(instanceID, basestring), ("instanceID must be a string but is %r" % instanceID)
  assert isinstance(tagName, basestring), ("tagName must be a string but is %r" % tagName)

  if not connection:
    # Assume AWS credentials are in the environment or the instance is using an IAM role
    connection = boto.ec2.connect_to_region(myRegion())

  # Filter the tag values for our instance_id
  # http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DescribeTags.html
  tagData = connection.get_all_tags(filters={"resource-id": instanceID, "key": tagName})
  if tagData:
    tagValue = tagData[0].value
  else:
    raise RuntimeError, "%s: No such tag on %s" % (tagName, instanceID)
  return tagValue
540389
public TagsUtils validateTags() {
    final List<String> instanceTags = getInstanceTags().stream()
        .map(Tag::getKey)
        .collect(Collectors.toList());

    final List<String> missingTags = getAwsTagNames().map(List::stream).orElse(Stream.empty())
        .filter(configuredTag -> !instanceTags.contains(configuredTag))
        .collect(Collectors.toList());

    if(!missingTags.isEmpty()) {
      throw new IllegalStateException("expected instance tag(s) missing: " + missingTags.stream().collect(Collectors.joining(", ")));
    }

    return this;
  }
1279429
public java.util.List<String> getInstancesToProtect() {
        if (instancesToProtect == null) {
            instancesToProtect = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return instancesToProtect;
    }
546631
def get_ec2_instances(self):
        
        log = logging.getLogger(self.cls_logger + '.get_ec2_instances')
        log.info('Describing EC2 instances...')
        try:
            response = self.client.describe_instances()
        except ClientError:
            _, ex, trace = sys.exc_info()
            msg = '{n}: There was a problem describing EC2 instances\n{e}'.format(n=ex.__class__.__name__, e=str(ex))
            raise EC2UtilError, msg, trace
        return response
409359
public java.util.List<InstanceCount> getInstanceCounts() {
        if (instanceCounts == null) {
            instanceCounts = new com.amazonaws.internal.SdkInternalList<InstanceCount>();
        }
        return instanceCounts;
    }
593447
public java.util.List<InstanceFleet> getInstanceFleets() {
        if (instanceFleets == null) {
            instanceFleets = new com.amazonaws.internal.SdkInternalList<InstanceFleet>();
        }
        return instanceFleets;
    }
1180175
def tags(instance)
      return [] if instance.groupSet.nil? || instance.groupSet.item.empty?
      instance.groupSet.item.collect{|g| g.groupId }.select {|s| s.start_with? "#poolparty"}
    end
119867
public java.util.List<? extends com.google.appengine.v1.InstanceOrBuilder> 
      getInstancesOrBuilderList() {
    return instances_;
  }
310130
def readMyEC2Tag(tagName, connection=None):
  
  assert isinstance(tagName, basestring), ("tagName must be a string but is %r" % tagName)

  # Load metadata. if == {} we are on localhost
  # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html

  if not connection:
    # Assume AWS credentials are in the environment or the instance is using an IAM role
    connection = boto.ec2.connect_to_region(myRegion())

  return readInstanceTag(connection=connection,
                         instanceID=myInstanceID(),
                         tagName=tagName)
519940
public static List<Image> describeAllImages() {
        // 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);

        // describe all AMIs in aws-mock.
        DescribeImagesResult result = amazonEC2Client.describeImages();

        return result.getImages();
    }
1354545
public java.util.List<AutoScalingInstanceDetails> getAutoScalingInstances() {
        if (autoScalingInstances == null) {
            autoScalingInstances = new com.amazonaws.internal.SdkInternalList<AutoScalingInstanceDetails>();
        }
        return autoScalingInstances;
    }
1183399
@Override
    public Map<String, List<CloudInstance>> getCloudInstances(CloudInstanceRepository repository) {
        DescribeInstancesResult instanceResult;
        if (null == settings.getFilters() || settings.getFilters().isEmpty() ) {
            instanceResult = ec2Client.describeInstances();
        } else {
            instanceResult = ec2Client.describeInstances(buildFilterRequest(settings.getFilters()));
        }
        DescribeAutoScalingInstancesResult autoScaleResult = autoScalingClient.describeAutoScalingInstances();
        List<AutoScalingInstanceDetails> autoScalingInstanceDetails = autoScaleResult.getAutoScalingInstances();
        Map<String, String> autoScaleMap = new HashMap<>();
        for (AutoScalingInstanceDetails ai : autoScalingInstanceDetails) {
            autoScaleMap.put(ai.getInstanceId(), ai.getAutoScalingGroupName());
        }

        Map<String, List<Instance>> ownerInstanceMap = new HashMap<>();

        List<Instance> instanceList = new ArrayList<>();
        List<Reservation> reservations = instanceResult.getReservations();
        for (Reservation currRes : reservations) {
            List<Instance> currInstanceList = currRes.getInstances();
            if (CollectionUtils.isEmpty(ownerInstanceMap.get(currRes.getOwnerId()))) {
                ownerInstanceMap.put(currRes.getOwnerId(), currRes.getInstances());
            } else {
                ownerInstanceMap.get(currRes.getOwnerId()).addAll(currRes.getInstances());
            }
            instanceList.addAll(currInstanceList);
        }

        Map<String, List<CloudInstance>> returnList = new HashMap<>();
        int i = 0;
        for (String acct : ownerInstanceMap.keySet()) {
            ArrayList<CloudInstance> rawDataList = new ArrayList<>();
            for (Instance currInstance : ownerInstanceMap.get(acct)) {
                i = i + 1;
                LOGGER.info("Collecting instance details for " + i + " of "
                        + instanceList.size() + ". Instance ID=" + currInstance.getInstanceId());
                CloudInstance object = getCloudInstanceDetails(acct,
                        currInstance, autoScaleMap, repository);
                rawDataList.add(object);
            }
            if (CollectionUtils.isEmpty(returnList.get(acct))) {
                returnList.put(acct, rawDataList);
            } else {
                returnList.get(acct).addAll(rawDataList);
            }
        }
        return returnList;
    }
847975
private Collection<AbstractMockEc2Instance> getInstances(final Set<String> instanceIDs) {
        Collection<AbstractMockEc2Instance> ret = new ArrayList<AbstractMockEc2Instance>();
        for (String instanceID : instanceIDs) {
            ret.add(getMockEc2Instance(instanceID));
        }
        return ret;
    }