Boto Cannot set SQS region in EC2 instance

248 views
Skip to first unread message

Abhishek Kona

unread,
Aug 30, 2010, 9:31:18 AM8/30/10
to boto-users
Hi

If I create SQS queue from an EC2 instance without specifying the
region in the API call, in which region will the queue be created.

When I run

boto.sqs.regions()

I get 4 regions from an NON ec2 machine, I get

[RegionInfo:us-east-1, RegionInfo:eu-west-1, RegionInfo:us-west-1,
RegionInfo:ap-southeast-1]

from a EC2 machine in the Asia Pacific Region I get

[RegionInfo:us-east-1, RegionInfo:eu-west-1, RegionInfo:us-west-1]

Does Amazon set region of SQS based on the EC2 instance region. Is
there a way to access other region Queues?

Mitchell Garnaat

unread,
Aug 30, 2010, 10:21:03 AM8/30/10
to boto-...@googlegroups.com
Hi -

If you don't pass in a "region" argument to the SQSConnection constructor (or the connect_sqs function) then the default behavior will be to connect to the us-east-1 region.  If you want to connect to another region, you would pass in a RegionInfo object as the "region" argument.  You can either construct that RegionInfo object manually or you can call the "regions" method to get a list of available regions.  As a short-cut, I have also added a "connect" method to the RegionInfo object that handles calling the SQSConnection constructor and passing in the correct RegionInfo object and returning the connection.

For the EC2 api actually provides a DescribeRegions request that allows you to programmatically get a list of all available regions.  Unfortunately, the other services do not support that so the list of available endpoints is actually defined in the boto module.  I suspect that you are using two different versions of boto on the EC2 machine and non-EC2 machine and the list of available regions in the module boto.sqs are different.

Could that be the case?

Mitch


--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.




--
Twitter: @garnaat
Voice: 480-442-BOTO

Abhishek Kona

unread,
Aug 30, 2010, 12:20:06 PM8/30/10
to boto-...@googlegroups.com
I am getting very weird behavior in my EC2 instance (it is running ubuntu)
I am just pasting a screen copy here.
I installed boto again (the latest version 2.0b2) on my EC2 instance,
In the Boto folder I get all the regions, out side of it
boto.sqs.regions() gives only 3 regions



My Screen clipping

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto.sqs
>>>
>>> print boto.sqs.regions()

[RegionInfo:us-east-1, RegionInfo:eu-west-1, RegionInfo:us-west-1, RegionInfo:ap-southeast-1]
>>> quit()
ubuntu@vivek:~/boto-2.0b2$ cd  ..
ubuntu@vivek:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto.sqss
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named sqss
>>> import boto.sqs
>>> print boto.sqs.regions()

[RegionInfo:us-east-1, RegionInfo:eu-west-1, RegionInfo:us-west-1]
>>>


Abhishek Kona

Mitchell Garnaat

unread,
Aug 30, 2010, 1:26:48 PM8/30/10
to boto-...@googlegroups.com
I think the problem is that your ubuntu instance in EC2 comes with a version of boto 1.9b installed and sometimes you are using that version.  To verify this, start up python somewhere outside of your boto distribution directory and type this:

>>> import boto
>>> boto.Version

I suspect you will see "1.9b" displayed.  To convince your instance to use the newly installed version of boto rather than 1.9b, you can try setting the PYTHONPATH environment variable to include your boto installation directory.

Did you run "sudo python setup.py install" in the boto 2.0b2 directory already?

Mitch
Reply all
Reply to author
Forward
0 new messages