Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple configurations #403

Open
Chen-George-Zhen opened this issue Dec 20, 2019 · 10 comments
Open

Support multiple configurations #403

Chen-George-Zhen opened this issue Dec 20, 2019 · 10 comments

Comments

@Chen-George-Zhen
Copy link

Support two or more aws configuration or specify configuration for model

@andrykonchin
Copy link
Member

Could you describe a case when this feature is needed?

@Chen-George-Zhen
Copy link
Author

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

@andrykonchin
Copy link
Member

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

@Chen-George-Zhen
Copy link
Author

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

@pboling
Copy link
Member

pboling commented Dec 26, 2019

I agree, option 1 seems preferable.

@dgarciacity
Copy link

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

@trevorh
Copy link

trevorh commented Mar 16, 2021

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).

@andrykonchin
Copy link
Member

Will prioritize this task 👍 .

@Fercell
Copy link

Fercell commented Mar 1, 2022

@andrykonchin any updates on this?

@andrykonchin
Copy link
Member

No, there is no update yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants