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

Read default region from ~/.aws/config #436

Open
adam-fowler opened this issue May 5, 2021 · 3 comments
Open

Read default region from ~/.aws/config #436

adam-fowler opened this issue May 5, 2021 · 3 comments

Comments

@adam-fowler
Copy link
Member

adam-fowler commented May 5, 2021

Steps

  • Add default region to AWSClient.
  • Read environment variable AWS_DEFAULT_REGION or value in ~/.aws/config. Will need to take into account AWS_PROFILE environment variable. Might need to do something to sync with ConfigFileCredentialProvider
  • To ensure this is done before any requests are made, need to do this before the credential provider setup is complete
  • If a service config has no region then should use default region from AWSClient.
  • As service can be created before AWSClient we cannot just copy default region to service. One way to avoid this is add new region useDefault which will use AWSClient default when a request occurs.
@eneko
Copy link
Contributor

eneko commented May 7, 2021

Question that comes to mind:

  • Since all services require an AWSClient, could we move the region to the client, and remove it from the services?

AWSClient would get the default region from ~/.aws/config using the profile from the credentials provider, if ConfigFileCredentialProvider was used. Otherwise, region would default to us-east-1. Users would be able to pass a region to AWSClient the same way they pass it to services today.

If the above worked, there would be no longer need to have region in the services, right? Would this be a valid/acceptable approach?

@adam-fowler
Copy link
Member Author

Question that comes to mind:

* Since all services require an `AWSClient`, could we move the region to the client, and remove it from the services?

Couple of reasons why we might not want to do this. 1) It is a breaking change, would need a new major version 2) Currently accessing a different region is a simple process which just involves creating a new version of the service ( which is a cheap operation ). Creating a new AWSClient is an expensive operation. Credential acquisition can take time. Also if you have a credentials that need refreshing having multiple AWSClients would mean you are doing this work multiple times.

@eneko
Copy link
Contributor

eneko commented May 17, 2021

Makes sense, thanks for clarifying.

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

2 participants