def machine_lookup_all(session, hostname, public_ip = True):
    """Lookup all of the IP addresses for a given AWS instance name.

    Multiple instances with the same name is a result of instances belonging to
    an auto scale group. Useful when an action needs to happen to all machines
    in an auto scale group.

    Args:
        session (Session) : Active Boto3 session
        hostname (string) : Hostname of the EC2 instances
        public_ip (bool) : Whether or not to return public IPs or private IPs

    Returns:
        (list) : List of IP addresses
    """
    client = session.client('ec2')
    response = client.describe_instances(Filters=[{"Name":"tag:Name", "Values":[hostname]},
                                                  {"Name":"instance-state-name", "Values":["running"]}])

    addresses = []
    items = response['Reservations']
    if len(items) > 0:
        for i in items:
            item = i['Instances'][0]
            if 'PublicIpAddress' in item and public_ip:
                addresses.append(item['PublicIpAddress'])
            elif 'PrivateIpAddress' in item and not public_ip:
                addresses.append(item['PrivateIpAddress'])
    return addresses