Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use DynamoDB Local with the AWS Ruby SDK?

Amazon's documentation provides examples in Java, .NET, and PHP of how to use DynamoDB Local. How do you do the same thing with the AWS Ruby SDK?

My guess is that you pass in some parameters during initialization, but I can't figure out what they are.

dynamo_db = AWS::DynamoDB.new(
  :access_key_id => '...',
  :secret_access_key => '...')
like image 790
Patrick Brinich-Langlois Avatar asked Oct 31 '14 17:10

Patrick Brinich-Langlois


1 Answers

Are you using v1 or v2 of the SDK? You'll need to find that out; from the short snippet above, it looks like v2. I've included both answers, just in case.

v1 answer:

AWS.config(use_ssl: false, dynamo_db: { api_verison: '2012-08-10', endpoint: 'localhost', port: '8080' })
dynamo_db = AWS::DynamoDB::Client.new

v2 answer:

require 'aws-sdk-core'
dynamo_db = Aws::DynamoDB::Client.new(endpoint: 'http://localhost:8080')

Change the port number as needed of course.

like image 92
Brian Deragon Avatar answered Sep 29 '22 00:09

Brian Deragon