How do I loop through regions using boto with python?
<p>Python newbie..
Im trying to write a script that will connect to my AWS account using the keys I give it and then it will list what instances are in there and will do so by looping through each region. So I want it to connect and start in a region and list and then go to the next region and list and so on.
The code below works if I comment out the following lines but it only works for us-east-1 which is my default region in my AWS credentials file on my box. 
"regions = boto.ec2.regions()
for x in regions:"
If I uncomment those lines the script will return all of my instances once for each region. So I end up with a huge list of the same instances repeating over and over. What am I missing that will make this do what im wanting? Be easy, im pretty new to Python.
Thanks.</p>

<pre><code>import boto.ec2
import os
import sys

ACCESS_KEY = raw_input("Enter your access key &gt; ")
SECRET_KEY = raw_input("Enter your secret key &gt; ")
if not ACCESS_KEY:
    sys.exit("ERROR: You did not enter anything for ACCESS KEY or SECRET KEY. Exiting...")

ec2_conn = boto.connect_ec2(ACCESS_KEY, SECRET_KEY)

regions = boto.ec2.regions()
for x in regions:
    reservations = ec2_conn.get_all_reservations()
    for r in reservations:
        for i in r.instances:
            print r.instances
            print 'Tags: ',i.tags['Name']
            print 'Public IP Address: ',i.ip_address
            print 'Private IP address: ',i.private_ip_address
            if (i.virtualization_type == 'hvm'):
                platform = 'Windows'
            else:
                platform = 'Linux'
                print 'Platform: ',platform
            print 'State: ',i.state
            print
</code></pre>