code: def wait_transition(resource, from_states, to_state,
                      state_getter=attrgetter('state')):
      
      state = state_getter(resource)
      while state in from_states:
          time.sleep(a_short_time)
          for attempt in retry_ec2():
              with attempt:
                  resource.update(validate=True)
          state = state_getter(resource)
      if state != to_state:
          raise UnexpectedResourceState(resource, to_state, state)
docs: Wait until the specified EC2 resource (instance, image, volume, ...) transitions from any
      of the given 'from' states to the specified 'to' state. If the instance is found in a state
      other that the to state or any of the from states, an exception will be thrown.
  
      :param resource: the resource to monitor
      :param from_states:
          a set of states that the resource is expected to be in before the  transition occurs
      :param to_state: the state of the resource when this method returns