def block_until_instance_ready(booting_instance, wait_time=5, extra_wait_time=20):
 _id = booting_instance.id
 _instance = EC2.Instance(id=_id)
 _state = _instance.state['Name']
 _ip = _instance.public_ip_address
 while ((_state != 'running') or (_ip is None)):
  time.sleep(wait_time)
  _instance = EC2.Instance(id=_id)
  _state = _instance.state['Name']
  _ip = _instance.public_ip_address
 block_until_ssh_open(_ip)
 time.sleep(extra_wait_time)
 return _instance

def block_until_instance_ready ( booting_instance , wait_time = 5 , extra_wait_time = 20 ) : _id = booting_instance . id _instance = EC2 . Instance ( id = _id ) _state = _instance . state [ 'Name' ] _ip = _instance . public_ip_address while ( ( _state != 'running' ) or ( _ip is None ) ) : time . sleep ( wait_time ) _instance = EC2 . Instance ( id = _id ) _state = _instance . state [ 'Name' ] _ip = _instance . public_ip_address block_until_ssh_open ( _ip ) time . sleep ( extra_wait_time ) return _instance
blocks booting_instance until aws ec2 instance is ready to accept ssh connections .