dynamoid icon indicating copy to clipboard operation
dynamoid copied to clipboard

Support multiple configurations

Open Chen-George-Zhen opened this issue 5 years ago • 12 comments

Support two or more aws configuration or specify configuration for model

Chen-George-Zhen avatar Dec 20 '19 07:12 Chen-George-Zhen

Could you describe a case when this feature is needed?

andrykonchin avatar Dec 20 '19 17:12 andrykonchin

Could you describe a case when this feature is needed?

Thank you, for example, in the same rails project, you need to connect two Amazon's DynamoDB, different access_key, secret_key, region

Chen-George-Zhen avatar Dec 24 '19 09:12 Chen-George-Zhen

I see. Will add this feature request for the next minor release in 3-4 months.

So actually there are two options:

  • to specify config options per model statically
  • to specify it dynamically

Let's consider both options. I am still not sure whether we need only one of them or both.

Option #1

Let's consider an example:

class User
  include Dynamoid::Document

  configure do |config|
    config.access_key = 'REPLACE_WITH_ACCESS_KEY_ID'
    config.secret_key = 'REPLACE_WITH_SECRET_ACCESS_KEY'
    config.region = 'us-west-2'    
  end
end

Option #2

Consider another example:

class User
  include Dynamoid::Document
end

Dynamoid.configure(access_key: '', secret_key: '', region: '') do
  User.count
end

andrykonchin avatar Dec 24 '19 16:12 andrykonchin

I see. Will add this feature request for the next minor release in 3-4 months.

So actually there are two options:

  • to specify config options per model statically
  • to specify it dynamically

Let's consider both options. I am still not sure whether we need only one of them or both.

Option #1

Let's consider an example:

class User
  include Dynamoid::Document

  configure do |config|
    config.access_key = 'REPLACE_WITH_ACCESS_KEY_ID'
    config.secret_key = 'REPLACE_WITH_SECRET_ACCESS_KEY'
    config.region = 'us-west-2'    
  end
end

Option #2

Consider another example:

class User
  include Dynamoid::Document
end

Dynamoid.configure(access_key: '', secret_key: '', region: '') do
  User.count
end

thank you very much! Specifying configuration options for the model is more flexible, If no configuration is specified, the default configuration is used. This is my humble opinion

Chen-George-Zhen avatar Dec 25 '19 02:12 Chen-George-Zhen

I agree, option 1 seems preferable.

pboling avatar Dec 26 '19 17:12 pboling

It would be very helpful, in my case I'm trying to use a different namespace for one model and it's not possible.

dgarciacity avatar Dec 02 '20 17:12 dgarciacity

I'd love to see a per-model configuration as well. This helps when needing to deal with data that's sourced from multiple regions (and the source applications can't be housed in a single region).

trevorh avatar Mar 16 '21 15:03 trevorh

Will prioritize this task 👍 .

andrykonchin avatar Mar 16 '21 18:03 andrykonchin

@andrykonchin any updates on this?

Fercell avatar Mar 01 '22 08:03 Fercell

No, there is no update yet.

andrykonchin avatar Mar 10 '22 16:03 andrykonchin