Sunday, April 6, 2014

AWS DynamoDB API calls not working? Could be the region is wrong

I was playing with Amazon Web Services recently, and one cool NoSQL database SAS (Software as a Service) they have is DynamoDB. As a ruby guy, I naturally used the AWS Ruby SDK to access it. Took me a while to figure out that I had to create a user in my account AND then add DynamoDB access permissions to the user before I can make DynamoDB API calls (AWS takes their security seriously, not bad ...).

I created a table and populated it with data via the browser, and I made API calls to it. But I kept getting  

AWS::DynamoDB::Errors::ResourceNotFoundException: Requested resource not found

Huh? The table is right there in the browser but the API call cannot find it! Turns out that the response is correct - the table does exist, but in a different AWS datacenter (or region). Just had to add the :region option.


dynamo_db = AWS::DynamoDB.new(:access_key_id => 'xxxx',:secret_access_key => 'xxxx',:region => 'your-region')


The exact region string can be (hopefully) inferred from the table details in the browser. An example is 'us-west-1'

I suspect the same pitfall may apply to other AWS services that are tied to regions.