def create_ami_from_instance(ec2client, instance, name, description,
    fingerprint):
    """Create an AMI from a running instance.

    Returns the ``ec2resource.Image`` representing the created AMI.
    """
    instance.stop()
    ec2client.get_waiter('instance_stopped').wait(InstanceIds=[instance.id],
        WaiterConfig={'Delay': 5})
    print('%s is stopped' % instance.id)
    image = instance.create_image(Name=name, Description=description)
    image.create_tags(Tags=[{'Key': 'HGIMAGEFINGERPRINT', 'Value':
        fingerprint}])
    print('waiting for image %s' % image.id)
    ec2client.get_waiter('image_available').wait(ImageIds=[image.id])
    print('image %s available as %s' % (image.id, image.name))
    return image
