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

Feature request: pre-populate Aws.config from environment #2112

Open
jonathanhefner opened this issue Aug 30, 2019 · 9 comments
Open

Feature request: pre-populate Aws.config from environment #2112

jonathanhefner opened this issue Aug 30, 2019 · 9 comments
Labels
feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release

Comments

@jonathanhefner
Copy link
Contributor

Issue description

Would it be feasible to pre-populate Aws.config from the runtime environment? For example, if ENV["AWS_REGION"] is set (and non-empty), then by default Aws.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:

Aws.config[:region] ||= "us-east-1"

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

@cjyclaire cjyclaire added the feature-request A feature should be added or improved. label Sep 10, 2019
@sivagollapalli
Copy link
Contributor

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

@mullermp
Copy link
Contributor

mullermp commented May 1, 2020

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"

@mullermp mullermp added the help wanted We are asking the community to submit a PR to resolve this issue. label May 1, 2020
@mullermp
Copy link
Contributor

mullermp commented May 1, 2020

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.

@alextwoods
Copy link
Contributor

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.

@mullermp mullermp added the needs-major-version Can only be considered for the next major release label May 1, 2020
@mullermp
Copy link
Contributor

mullermp commented May 1, 2020

Marking as needs-major-version for now.

@sivagollapalli
Copy link
Contributor

sivagollapalli commented May 2, 2020

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

@mullermp
Copy link
Contributor

mullermp commented May 4, 2020

@github-actions
Copy link

github-actions bot commented May 5, 2021

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.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 5, 2021
@mullermp mullermp removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 5, 2021
@github-actions
Copy link

github-actions bot commented May 6, 2022

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.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 6, 2022
@mullermp mullermp removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 6, 2022
@mullermp mullermp added no-autoclose and removed help wanted We are asking the community to submit a PR to resolve this issue. labels Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release
Projects
None yet
5 participants