Reputation: 652
I'm trying to obtain a list of all my AWS RDS instances using Python's Boto module. I can obtain the instance metadata fine which I then read into the connection to utilise get_all_dbinstances()
but keep getting [] returned.
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
>> []
Upvotes: 0
Views: 931
Reputation: 45856
The call to connect_to_region
actually returns an RDSConnection
object for that region so your code should really look like this:
rds = boto.rds.connect_to_region('eu-central-1', ...)
instances = rds.get_all_dbinstances()
Your original code is ignoring the region part and just getting a connection to the default region (us-east-1
) where you obviously have no DB instances running.
Upvotes: 3