我想用 boto 获取 LoadBalancer 上的所有实例,我该如何实现?
这是我到目前为止所得到的:
import boto
from boto.regioninfo import RegionInfo
from boto import ec2
ACCESS_KEY_ID = '*****'
SECRET_ACCESS_KEY = '********'
reg = RegionInfo(
name='ap-southeast-1',
endpoint='elasticloadbalancing.ap-southeast-1.amazonaws.com')
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)
以:
<ErrorResponse xmlns="http://webservices.amazon.com/AWSFault/2005-15-09"> <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>
我正在使用 boto 2.4.1。