Open jonathanhefner opened 5 years ago
I think this feature already included. Here is the documentation https://github.com/aws/aws-sdk-ruby#configuration. Let me know if I missed anything. @jonathanhefner @cjyclaire
I don't think so.
mamuller@4c327598178f:~/workplace/aws-sdk-ruby$ gems/aws-sdk-resources/bin/aws-v3.rb -v
Aws> s3.config.region # region loaded from ~/.aws/config
=> "us-west-2"
Aws> Aws.config[:region] ||= "us-east-1" # expect this to be us-west-2 and not us-east-1
=> "us-east-1"
Aws> Aws.config[:region]
=> "us-east-1"
This may be a tricky one to implement. I would think that whatever configuration is resolved from the credential provider would need to be merged (or overwritten? unsure) into the Aws.config
hash.
We could implement it by using a block for defaults on Aws.config eg, when defining it:
# lib/aws-sdk-core.rb
@config = Hash.new { |hash, key| hash[key] = Aws.shared_config.send(key) if Aws.shared_config.respond_to?(key) }
I'm a little wary of making changes to default behavior of Aws.config though.
Marking as needs-major-version for now.
We could implement it by using a block for defaults on Aws.config eg, when defining it:
# lib/aws-sdk-core.rb @config = Hash.new { |hash, key| hash[key] = Aws.shared_config.send(key) if Aws.shared_config.respond_to?(key) }
I'm a little wary of making changes to default behavior of Aws.config though.
@alextwoods Above code works.
Question here is, what If ~/.aws/config
default region value is different from ENV['AWS_REGION']
then which value should it pick it up? @mullermp
It should prefer ENV over everything else. https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html#aws-ruby-sdk-setting-credentials
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.
Issue description
Would it be feasible to pre-populate
Aws.config
from the runtime environment? For example, ifENV["AWS_REGION"]
is set (and non-empty), then by defaultAws.config[:region] == ENV["AWS_REGION"]
. Likewise for any settings picked up from "~/.aws" or elsewhere.This would enable in-app configuration code like the following:
Where a reasonable default is provided, but can overridden from the outside, without code modification.
Additionally, it may be useful when one wants to test what config values are being picked up from the environment, for example, when debugging.
Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk
Version of Ruby, OS environment
any
Code snippets / steps to reproduce
N/A