'Configure the given AWS instance, wait until it\'s running
and create an ``AWSNode`` object for it.
:param reactor: The reactor.
:param boto.ec2.instance.Instance instance: The instance to set up.
:param dict metadata: The metadata to set for the instance.
:return: Deferred that fires when the instance is ready.'

def _async_get_node(self, reactor, instance, metadata):

    def instance_error(failure):
        Message.log(message_type='flocker:provision:aws:async_get_node:failed')
        instance.terminate()
        write_failure(failure)
        return failure
    action = start_action(action_type=u'flocker:provision:aws:async_get_node', name=metadata['Name'], instance_id=instance.id)
    with action.context():
        d = loop_until(reactor, (lambda : maybeDeferred(self._set_metadata, instance, metadata)), repeat(5, INSTANCE_TIMEOUT))
        d = DeferredContext(d)
        d.addCallback((lambda _: _async_wait_until_running(reactor, instance)))
        d.addErrback(instance_error)
        d.addActionFinish()
        return d.result
