8

I am writing a python script that starts a specific instance that is currently stopped, and I am kind of stumped on how I'd do that. As far as I can understand from the Boto EC2 introduction on launching instances this creates a completely new instance?

conn.run_instances(
    '<ami-image-id>',
    key_name='myKey',
    instance_type='c1.xlarge',
    security_groups=['your-security-group-here'])

Code examples would be very welcome!

2 Answers 2

11

I had completely missed this command in the API

For future reference, this is how to start a stopped instance:

instance = conn.get_all_instances(instance_ids=['instance_id'])
print instance[0].instances[0].start()
1
  • 6
    Looks like get_all_instances() has deprecated functionality and actually returns a list of Reservation objects. So it's more favorable to use: instances=conn.get_only_instances(instance_ids=['instance_id']) So that you can then: instances[0].start()
    – joeymink
    Feb 21, 2014 at 16:54
4

You can now start multiple instances in one start_instances call, e.g.:

conn.start_instances(instance_ids=['instance_id_1', 'instance_id_2',])

See http://boto.cloudhackers.com/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.start_instances

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.