Search code examples
pythonpython-2.7amazon-web-servicesbotords

Not able to retrieve information about db instances from the describe_instance method using boto.rds2


import boto.rds2
conn = boto.rds2.connect_to_region("us-east-1")
def status(conn):
    response = conn.describe_db_instances()
    instances=responses['DescribeDBInstancesResponse'] ['DescribeDBInstancesResult'] 
['DBInstances']

print(instances['Engine'])

I want to get information about rds instances using the following code . why am i not able to get it Engine= mysql/sqlserver?. I am getting a list of dictionaries to the response variable. i want the output to be stored in a dictionary or list so that i can easily access those variables later.


Solution

  • The following code should work for you:

    def status(conn):
        status_map = {}
        response = conn.describe_db_instances()
        instances = response['DescribeDBInstancesResponse']['DescribeDBInstancesResult']['DBInstances']
        for instance in instances:
            status_map[instance['DBInstanceIdentifier']] = instance['Engine']
        return status_map