Search code examples
pythonamazon-web-servicesbotords

Difficulty in finding the Region names in AWS rds


How to get the names of all the rds instances in AWS using a boto script. I want to write a python script that fetches all the regions and then displays their dbinstances.


Solution

  • The following should give you all of the available regions for RDS.

    import boto.rds
    regions = boto.rds.regions()
    

    Which would return a list of RegionInfo objects like this.

    [RegionInfo:us-east-1,
     RegionInfo:cn-north-1,
     RegionInfo:ap-northeast-1,
     RegionInfo:eu-west-1,
     RegionInfo:ap-southeast-1,
     RegionInfo:ap-southeast-2,
     RegionInfo:us-west-2,
     RegionInfo:us-gov-west-1,
     RegionInfo:us-west-1,
     RegionInfo:eu-central-1,
     RegionInfo:sa-east-1]
    

    If you then wanted to connect to one particular region, say eu-west-1 you could do this:

    region = regions[6]
    conn = region.connect()
    

    or even:

    conn = boto.rds.connect_to_region(region.name)