Re: [boto-users] Is it possible to get the addresses for the instances in a load balancer?

54 views
Skip to first unread message

Mitchell Garnaat

unread,
Jun 9, 2012, 9:43:12 AM6/9/12
to boto-...@googlegroups.com
Hi -

I replied to the stackoverflow thread, too.  The problem is that you create a RegionInfo that includes the endpoint for ELB and then you pass that RegionInfo when you create the EC2 connection object.

An easier way (perhaps) might be something like this:

import boto.ec2
import boto.ec2.elb

elb_connection = boto.ec2.elb.connect_to_region('ap-southeast-1')
ec2_connection = boto.ec2.connect_to_region('ap-southeast-1')

Then you don't have to mess around with RegionInfo.

Mitch

On Sat, Jun 9, 2012 at 5:53 AM, Kit Sunde <kits...@gmail.com> wrote:
I'm using boto 2.4.1 and I'm attempting to grab all the addresses for the instances in a load balancer and I've ended up with this:

import boto
from boto import ec2
from boto.regioninfo import RegionInfo

ACCESS_KEY_ID = '*****'
SECRET_ACCESS_KEY = '********'

reg = RegionInfo(
    name='ap-southeast-1', 

conn = boto.connect_elb(
    aws_access_key_id=ACCESS_KEY_ID, 
    aws_secret_access_key=SECRET_ACCESS_KEY, 
    region=reg)

ec2_connection = boto.ec2.connection.EC2Connection(
    aws_access_key_id=ACCESS_KEY, 
    aws_secret_access_key=SECRET_ACCESS_KEY,
    region=reg)

instances = [ instance.id for instance in conn.get_all_load_balancers()[3].instances ] 
# instances is now [u'i-62448d36'], so far so good.
ec2_connection.get_all_instances(instances)

But I'm now getting back an error suggesting that AWS isn't liking get_all_instances:

  <Error>
    <Type>Sender</Type>
    <Code>InvalidAction</Code>
    <Message>Could not find operation DescribeInstances for version 2012-03-01</Message>
  </Error>
  <RequestId>c6aab70d-b22b-11e1-a990-a747bbde9f63</RequestId>
</ErrorResponse>

Any way I can get around that?

--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/boto-users/-/UqX1awd4lAIJ.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.

Reply all
Reply to author
Forward
0 new messages