Skip to content

Instantly share code, notes, and snippets.

@shio-phys
Created March 1, 2016 06:54
Show Gist options
  • Save shio-phys/cde867561a0296298bd3 to your computer and use it in GitHub Desktop.
Save shio-phys/cde867561a0296298bd3 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require 'aws-sdk'
class DynamoDB
@@dynamodb = nil
def self.instance
return @@dynamodb if @@dynamodb
credentials = Aws::Credentials.new('aws_access_key', 'aws_secret_key')
dynamo_config = { region: 'ap-northeast-1', credentials: credentials, }
if Rails.env != 'production' #本番環境以外ではDynamoDB Localを利用
dynamo_config[:endpoint] = "http://localhost:8000"
end
@@dynamodb = Aws::DynamoDB::Client.new(dynamo_config)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment