EC2: Waiting until a new instance is in running state

前端 未结 6 2213
死守一世寂寞
死守一世寂寞 2021-02-19 23:33

I would like to create a new instance based on my stored AMI.

I achieve this by the following code:

RunInstancesRequest rir = new RunInstancesRequest(ima         


        
6条回答
  •  囚心锁ツ
    2021-02-19 23:48

    Waiting for the EC2 instance to get ready is a common pattern. In the Python library boto you also solve this with sleep calls:

       reservation = conn.run_instances([Instance configuration here])
       instance = reservation.instances[0]
    
       while instance.state != 'running':
           print '...instance is %s' % instance.state
           time.sleep(10)
           instance.update()
    

    With this mechanism you will be able to poll when your new instance will come up.

提交回复
热议问题