Python Boto rds.get_all_dbinstances返回空列表
我正在尝试使用Python的Boto模块获取所有AWS RDS实例的列表。我可以获取实例元数据,然后将其读入连接中,以使用Python Boto rds.get_all_dbinstances返回空列表,python,amazon-web-services,boto,amazon-rds,Python,Amazon Web Services,Boto,Amazon Rds,我正在尝试使用Python的Boto模块获取所有AWS RDS实例的列表。我可以获取实例元数据,然后将其读入连接中,以使用get\u all\u dbinstances()但继续获取[]返回值 from boto.utils import get_instance_metadata import boto.rds # This works fine m = get_instance_metadata() access_key = m[****] secret_key = m[***
get\u all\u dbinstances()
但继续获取[]返回值
from boto.utils import get_instance_metadata
import boto.rds
# This works fine
m = get_instance_metadata()
access_key = m[****]
secret_key = m[****]
security_token = m[****]
try:
# And this works fine
region_object = boto.rds.connect_to_region("eu-central-1", aws_access_key_id=access_key, aws_secret_access_key=secret_key)
except ValueError, e:
print "Error: {0}".format(e.message)
rds = boto.connect_rds(aws_access_key_id = access_key, aws_secret_access_key = secret_key, security_token = security_token, region=region_object.region)
instances = rds.get_all_dbinstances()
print instances
>> []
调用
connect\u to\u region
实际上会返回该区域的RDSConnection
对象,因此您的代码应该如下所示:
rds = boto.rds.connect_to_region('eu-central-1', ...)
instances = rds.get_all_dbinstances()
您的原始代码忽略了区域部分,只是获得到默认区域的连接(
us-east-1
),在默认区域中,您显然没有运行DB实例。调用connect\u to\u region
实际上返回了该区域的RDSConnection
对象,因此您的代码应该是这样的:
rds = boto.rds.connect_to_region('eu-central-1', ...)
instances = rds.get_all_dbinstances()
您的原始代码忽略了区域部分,只是获得到默认区域的连接(
us-east-1
),在默认区域中,您显然没有运行DB实例。调用connect\u to\u region
实际上返回了该区域的RDSConnection
对象,因此您的代码应该是这样的:
rds = boto.rds.connect_to_region('eu-central-1', ...)
instances = rds.get_all_dbinstances()
您的原始代码忽略了区域部分,只是获得到默认区域的连接(
us-east-1
),在默认区域中,您显然没有运行DB实例。调用connect\u to\u region
实际上返回了该区域的RDSConnection
对象,因此您的代码应该是这样的:
rds = boto.rds.connect_to_region('eu-central-1', ...)
instances = rds.get_all_dbinstances()
您的原始代码忽略了区域部分,只是连接到默认区域(
us-east-1
),您显然没有运行DB实例。谢谢,这是一个区域问题,我位于爱尔兰,所以我的区域是eu-west-1,而不是eu-central-1感谢,这是一个区域问题,我住在爱尔兰,所以我所在的地区是eu-west-1而不是eu-central-1,这是一个地区问题,我住在爱尔兰,所以我所在的地区是eu-west-1而不是eu-central-1,这是一个地区问题,我住在爱尔兰,所以我所在的地区是eu-west-1而不是eu-central-1