def get_images_in_use(ec2):
    """
    Returns a list of image IDs in use by any EC2 instance.
    """
    amis = set()

    for instance in ec2.instances.all():
        amis.add(instance.image_id)

    return amis