Explicitly Setting an AWS SimpleDb Region in PHP


I am experimenting with AWS SimpleDB on a new PHP project. When I attempted to query a domain, I got no response. I used firephp (firephp.org) to log the result of the query in firebug. The result was a CFResponse object. By looking inside the object, I saw that it produced a “No such domain” error. I figured that it must be querying in the wrong region, so I decided to set that explicitly.

I looked in the php sdk and found the set_region($region) method in sdb.class.php. According to the in-file documentation the options for $region are: <REGION_US_E1>, <REGION_US_W1>, <REGION_US_W2>, <REGION_EU_W1>, <REGION_APAC_SE1>, <REGION_APAC_NE1>, <REGION_SA_E1>. I wasn’t sure how exactly the option should look when passed into set_region. I tried set_region(“REGION_US_E1”). I tried set_region(“<REGION_US_E1>”). I even tried set_region(<REGION_US_E1>). None of those worked. They gave the error “Fatal error: Uncaught exception ‘cURL_Exception’ with message ‘cURL resource: Resource id #37; cURL error: Could not resolve host: REGION_US_E1; Host not found (cURL error code 6). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes.’

Eventually, I found a forum post (which I can’t now find) that provided the correct syntax (although I think it was for AWS SQS). Here it is: set_region(AmazonSDB::REGION_VIRGINIA) — no quotes. You can find the correct region name in sdb.class.php in lines 43-118.


Leave a Reply

Your email address will not be published. Required fields are marked *