Earlier this week I began implementing a DynamoDB solution for a client. DynamoDB is a NoSQL solution long ago planned but only recently released on Amazon Web Services. It is more closely related to Cassandra than MongoDB or CouchDB but offers some interesting and enticing features (e.g., all DynamoDB tables exist on SSDs, so the I/O is pretty damn fast!). 

My client's site is built with CFML and runs on Tomcat/Railo 3.3.1 (to be upgraded to 3.3.2 this weekend) on a load-balanced EC2 instance that employs several other AWS services, such as a MySQL DB on RDS, S3, CloudFront and the new ElastiCache. While our RDS database serves most of our needs, some of our data is quite complex and we feel we would better served breaking some items out into a NoSQL solution. 

After an initial review of NoSQL options, we thought we'd go with MongoDB but, with the announcement of DynamoDB, we decided that it would be a better choice for our team because all DynamoDB instances are managed by Amazon's experts ... and this seemed a might better option than building and managing our own MongoDB cluster!

As many/most CFML developers know, there is no CFML SDK for Amazon Web Services. And, if you want to write CFML code to directly access AWS services such as DynamoDB, it can be a pain in the ass, to say the least.

Why such a pain? Primarily because you have to manage your security credentials and session tokens yourself/in your CFML code and none of these actions are straight-forward or easy. Plus, it ends up pretty non-CFMLy because it requires a shit-ton of code (IMHO). The pre-built AWS SDKs, on the other hand, handle all these security actions for you. 

Fortunately, there is an AWS Java SDK, as I am sure you all know. And, thankfully, we CFML developers can (fairly) easily access and use Java APIs/libraries directly in our CFML code. Hooray!

So, to make my life easier, I created and started working on a project I named CFDynamo (yep, typically uninspired CFML project name :). To start, I have integrated the security aspect (i.e., enabling CFDynamo to access your DynamoDB instance) and table listings. To get started quicker, I created a couple of tables in the AWS console. 

If you are interested in the project, please check it out on Github. The README contains instructions for getting the Java SDK setup and running on either Tomcat/Railo or ACF 9. I won't bore you with more setup details here.

I'll be adding more API functions/calls to CFDynamo between today and Monday. Feel free to watch the Github repo for updates, which should come in the following order: 

  • createTable
  • deleteTable
  • updateTable
  • getItem
  • updateItem
  • query
  • scan
  • refine putItem

And, of course, please fork the project and make some better coding updates than I will and I can merge your pull requests!

Posted via email from self.is_a? Blog

Comments

Rupert
Have you tried using DynamoDB for session storage? Amazon have released some support for PHP, but nothing for Railo.

http://aws.typepad.com/aws/2012/04/scalable-session-handling-in-php-using-amazon-dynamodb.html
Gus
To use SSL you will need to import the cert into the java keystore. First, export the cert from https://dynamodb.us-east-1.amazonaws.com/ or whereever your endpoint is. You can do this with firefox.

Then run the following command from a command prompt to import the cert you downloaded:

keytool -import -trustcacerts -keystore %COLDFUSION DIR%/runtime/jre/lib/security/cacerts -storepass changeit -noprompt -alias ANYALIAS
-file PATH-TO-THE-CERT

Finally restart CF and you should be good to go.
Craig Kaminsky
Thanks, Gus! I will update accordingly.
gus
There is a problem with the java SSL key store on your server. If you don't need to use SSL add this after line 15 of DynamoClient.cfc

variables.aws_dynamodb.setEndpoint('http://dynamodb.us-east-1.amazonaws.com');

This will use http instead of https and avoid any key store issues.
Ryan
I'm getting "Unable to execute HTTP request: peer not authenticated" when making a request. Any idea?