soto-core
soto-core copied to clipboard
Read default region from `~/.aws/config`
Steps
- Add default region to
AWSClient
. - Read environment variable
AWS_DEFAULT_REGION
or value in~/.aws/config
. Will need to take into accountAWS_PROFILE
environment variable. Might need to do something to sync withConfigFileCredentialProvider
- 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 regionuseDefault
which will useAWSClient
default when a request occurs.
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?
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 AWSClient
s would mean you are doing this work multiple times.
Makes sense, thanks for clarifying.