dynamoid
dynamoid copied to clipboard
am I able to configure API calls to use different set of AWS credentials, table, with the same model?
I want to do something like this:
env1_results = MyModel.find(...) # where table name is TEST_MY_MODEL
env2_results = MyModel.find(...) # where table name is ALPHA_MY_MODEL and a different set of AWS credentials
Is this possible?
Currently, Dynamoid is configured with Dynamoid.configure and Aws.config.update
Right now it isn't supported. Could you please describe your use case? There is a similar issue - #403 and a discussion #509.
Thank you, we have a similar use case to #403 where we need to access multiple accounts' tables with the same model.
Is switching to an AWS account that you need temporary and local? And a desirable API is close to the second option from the #403:
Dynamoid.configure(config_options) do
User.count
end
I am looking at the Rails Multiple Databases with Active Record guide - they provide means to dynamically switch to some predefined database shard in the similar way:
ActiveRecord::Base.connected_to(role: :writing, shard: :shard_one) do
Person.find(@id) # Can't find record, doesn't exist because it was created
# in the shard named ":default".
end
Thanks for clarifying. I would require the second option as you mentioned. Following your example, I need to get the same model,User.count from different AWS accounts.
Is switching to an AWS account that you need temporary and local?
No, we maintain large amounts of accounts in our staging environment that is semi-produciton, that we regularly configure and sync to and from production. I've been using a hodgepodge of "copy to environment" APIs and the DynamoDB Ruby SDK, but they are getting out of control and would much prefer to work with Dynamoid models directly to query and write for cross-account data.
@rhuang I think you should be able to do this with cross-account permissions.
- In your staging account give write access to the production account for the DynamoDB table.
- On the production account codebase, extend a model and set the table name to the ARN of a staging table