Last active
July 15, 2020 09:43
-
-
Save indyarocks/3a6439604fe2f4e1331aa7fa98afb930 to your computer and use it in GitHub Desktop.
DynamoDB Client for Rails Application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## /config/initializers/dynamodb_client.rb | |
module DynamodbClient | |
def self.initialize! | |
client_config = if Rails.env.development? | |
{ | |
region: 'us-west-2', | |
endpoint: 'http://localhost:8000' | |
} | |
else | |
{ | |
access_key_id: Rails.application.secrets.dynamodb_access_key_id, | |
secret_access_key: Rails.application.secrets.dynamodb_secret_access_key, | |
region: Rails.application.secrets.dynamodb_region | |
} | |
end | |
@@client ||= Aws::DynamoDB::Client.new(client_config) | |
end | |
module_function | |
def client | |
@@client | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same here.