python - AutoScaleConnection.get_all_groups() 不适用于 boto

标签 python boto

我尝试连接到 aws autoscale 并获取所有组。我收到以下错误:

from boto import ec2
from boto.ec2.autoscale import AutoScaleConnection
import boto
AWS_ACCESS_KEY = "<key>"
AWS_SECRET_KEY = "secret"
REGION = 'us-west-1'
region_info = boto.ec2.get_region('us-west-1')

conn = AutoScaleConnection(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY, region=region_info)

conn.get_all_groups()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/autoscale/__init__.py", line 342, in get_all_groups
    [('member', AutoScalingGroup)])
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1185, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidAction</Code><Message>The action DescribeAutoScalingGroups is not valid for this web service.</Message></Error></Errors><RequestID>sadsdasdsdsdsadasdasd</RequestID></Response>

我尝试了另一种方法:这有效

conn = boto.ec2.autoscale.connect_to_region('us-west-1')
conn.get_all_groups()

但我不想使用 boto 存储的默认配置文件。我想提供访问 key 等作为参数(如上面的示例中尝试的那样)

感谢任何帮助。

我正在关注本教程:http://boto.readthedocs.org/en/latest/autoscale_tut.html

最佳答案

您仍然可以将显式凭据传递给 connect_to_region 方法,如下所示:

import boto.ec2.autoscale
conn = boto.ec2.autoscale.connect_to_region('us-west-2', aws_access_key_id='YOUR_ACCESS_KEY', aws_secret_access_key='YOUR_SECRET_KEY')
conn.get_all_groups()

这样您就可以让 boto 为您处理创建 RegionInfo 对象的复杂问题。

关于python - AutoScaleConnection.get_all_groups() 不适用于 boto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29237653/

相关文章:

python - CVXPY 抛出 SolverError

python - 奇怪的打印......硬件

python - 单词列表的词形还原

python - 使用 Amazon s3 时 Django ImageField url 变慢

python - 试图理解 Django 源代码和缺少参数 TypeError 的原因

python - 如何设置Python路径以便找到模块?

python - Numpy 在行上循环追加二维数组

python - 如何用Python预测第二天的股价?

python - 将图像上传到 S3 (boto + GAE)

aws-cloudformation - 如果已连接,则允许重新关联弹性 IP