1

I try to list all instances in account, using code:

for region in boto.ec2.regions(**creds):
    print region.name
    ec2_conn = boto.ec2.connect_to_region(region.name, **creds)

    for instance in ec2_conn.get_only_instances():
        print instance

But it fails when checking region "us-gov-west-1" with error:

boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized AuthFailureAWS was not able to validate the provided access credentialsc873c473-c3b1-4be3-b562-b2e73b21e9c2

As I understand that region is some special goverment region not allowed for me to use. But how than ignore it? I can just wrap my loop in try ... except but may be there is some way to get the list of only accessible regions?

UPD: When iterating throught regions with following code:

ec2_conn = boto.ec2.connection.EC2Connection(**creds)
for region in ec2_conn.get_all_regions():

gives no "us-gov-west-1" region. But why this methods give different results and when each should be used?

Bunyk
  • 7,635
  • 8
  • 47
  • 79

1 Answers1

5

Found it!

boto.ec2.regions() gives us list of all existing regions, which is hardcoded in the library, and

boto.ec2.connection.EC2Connection::get_all_regions() does actuall call to DescribeRegions, to get list of regions currently available.

As somebody said: read the source Luke!

Bunyk
  • 7,635
  • 8
  • 47
  • 79
  • Also, I think you will need separate credentials or at least credentials that have been explicitly authorized for GovCloud. – garnaat Dec 24 '13 at 16:45