0

我正在使用 boto python 模块来轮询亚马逊 ec2 实例,但是它返回空值,

我可以使用 conn.get_all_images 检索和列出图像

import sys
from boto.ec2.connection import EC2Connection

conn = EC2Connection('access key','secret key')
inst = conn.get_all_instances()
for i in inst:
    print i

我从python命令行尝试过它也有相同的结果

>>>import sys
>>>from boto.ec2.connection import EC2Connection
>>>conn = EC2Connection('access key','secret key')
>>> instances = conn.get_all_instances()
>>> instances
[]
>>>

知道问题可能是什么吗?谢谢

4

1 回答 1

1

我在看错误的区域,当我使用正确的区域时修复了..

regions = boto.ec2.regions(aws_access_key_id=AWS_ACCESS_KEY_ID,aws_secret_access_key=AWS_SECRET_ACCESS_KEY,is_secure=False)
eu = regions[0]
conn_eu = eu.connect(aws_access_key_id=AWS_ACCESS_KEY_ID,aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
        inst = conn_eu.get_all_instances()
于 2011-12-09T11:36:49.553 回答