mackwerk
mackwerk

Reputation: 1687

Starting a stopped EC2 instance with Boto

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!

Upvotes: 8

Views: 9223

Answers (2)

rakslice
rakslice

Reputation: 8975

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

Upvotes: 4

mackwerk
mackwerk

Reputation: 1687

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()

Upvotes: 11

Related Questions