Veraticus/Dynamoid — pull request #77 by indykish (2012-10-28 10:19:35+00:00)
Title: Configuration support using aws.yml file, and fix for the error when using aws-sdk 1.6.9 version.

Our rails application worked with Dynamoid (latest 0.5.0), aws-sdk 1.4.1.

Moving the aws-sdk gem to 1.6.9, the rails application failed to start with the following error.

'```ruby
rails s
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect SYSCALL returned=5 errno=0 state=unknown state (OpenSSL::SSL::SSLError)
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:799:in `connect'
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /home/ram/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:750:in `start'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/net/http/connection_pool/session.rb:118:in `start'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/dynamodb.ap-southeast-1.amazonaws.comgems/aws-sdk-1.6.9/lib/net/http/connection_pool.rb:208:in `_create_session'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/net/http/connection_pool.rb:193:in `session_for'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/net/http/connection_pool.rb:171:in `request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/net/http/connection_pool/connection.rb:173:in `request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/http/net_http_handler.rb:70:in `handle'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:230:in `block in make_sync_request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:259:in `retry_server_errors'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:226:in `make_sync_request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:451:in `block (2 levels) in client_request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:334:in `log_client_request'
from /home/ram/.rvm/gems/ruby-1.9.3-p286/gems/aws-sdk-1.6.9/lib/aws/core/client.rb:420:in `block in client_request'
'```

* Debugging the problem showed that aws-sdk moved away from the Signer used in 1.4.1 version to CredentialProvider approach in its current version.

* Also the configuration as passed in the adapter/aws-sdk.rb wasn't picked up by the client.rb code of aws. Additionally we also use S3 and plan to use cloudfront.

* We didn't like the approach of storing access_* keys for AWS in multiple places ie, in the dynamoid.rb initializer and aws.yml file. And it seemed logical to just store the config parms needed for Dynamoid under dynamoid.rb.

* Also storing all the configuration as needed in the aws.yml file, and instantiating the AWS::Dynamoid.new with no paramters resulted in aws-sdk picking up the configuration from aws.yml file.

Voila this solve two problems for us (the stack shown earlier and usage of common config).*