EC2: Waiting until a new instance is in running state

前端 未结 6 2175
死守一世寂寞
死守一世寂寞 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:47

    From the AWS CLI changelog for v1.6.0:

    Add a wait subcommand that allows for a command to block until an AWS resource reaches a given state (issue 992, issue 985)

    I don't see this mentioned in the documentation, but the following worked for me:

    aws ec2 start-instances --instance-ids "i-XXXXXXXX"
    aws ec2 wait instance-running --instance-ids "i-XXXXXXXX"
    

    The wait instance-running line did not finish until the EC2 instance was running.

    I don't use Python/boto/botocore but assume it has something similar. Check out waiter.py on Github.

提交回复
热议问题