Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get instance by instance-id

I need to get the instance by instance-id, is it possible to do it without requesting a list of all instances?

I've tried:

ec2_conn = boto.connect_ec2(aws_access_key_id=key, aws_secret_access_key=access)
c2.get_all_instances([instanceId])

It works, but is there some other way to get the instance?

The reason I'm asking is I received UnauthorizedOperation for get_all_instances request, so I would prefer to change the request, not the security settings.

like image 728
Francheska Avatar asked Aug 23 '12 16:08

Francheska


1 Answers

Maybe boto has evolved since the time the OP asked the question, but this deserves the up to date answer to be added here:

reservations = ec2conn.get_all_instances(instance_ids=['i-12345678'])
instance = reservations[0].instances[0]
like image 60
Tisho Avatar answered Oct 24 '22 19:10

Tisho