Skip to content

config file isn't checked for region #1039

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

Closed
jjshoe opened this issue Jun 29, 2016 · 5 comments · Fixed by #1391
Closed

config file isn't checked for region #1039

jjshoe opened this issue Jun 29, 2016 · 5 comments · Fixed by #1391
Assignees
Labels
feature-request A feature should be added or improved.

Comments

@jjshoe
Copy link

jjshoe commented Jun 29, 2016

Version: 2.4.3
~/.aws/config isn't checked for region information when trying to perform a connection.

To reproduce:

~/.aws/config:

[default]
region=us-east-1

~/.aws/credentials:

[default]
aws_access_key_id = changed
aws_secret_access_key = changed

~/test.js:

var AWS = require('aws-sdk');

// Get a list of kms keys
var kms = new AWS.KMS();

var params = {
  Limit: 0,
  Marker: 'STRING_VALUE'
};

kms.listKeys(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Also worth noting, if I rm ~/.aws/credentials, put aws_access_key_id and aws_secret_access_key in ~/.aws/config I still get the above error.

Relevant doc on how the AWS cli precedence: http://docs.aws.amazon.com/cli/latest/topic/config-vars.html#id1

@LiuJoyceC
Copy link
Contributor

Hi @jjshoe
The SDK does not currently support sourcing configuration from ~/.aws/config, as this is intended for the AWS CLI.
These are the supported ways for configuring the region in the AWS SDK for JavaScript:

You update the region in your code using AWS.config.update():

AWS.config.update({region: 'us-east-1'});

Or you can set your environment variable AWS_REGION to the desired region, and this will allow you to keep the region private and not hard-code it in your code.

Or you could also set your configuration, including the region, in a .json file, and then load it by providing the file path to AWS.config.loadFromPath():

AWS.config.loadFromPath('./myConfiguration.json');

Note that using this method will delete and replace your existing configuration with the configuration in your .json file, so you will either need to specify all of your global configuration here or load it first before updating any additional configuration.

Let me know if that resolves the error you're running into!

@LiuJoyceC LiuJoyceC self-assigned this Jun 29, 2016
@LiuJoyceC
Copy link
Contributor

This is a feature request that we are looking into implementing in the future.

@brettbeatty
Copy link

I, too, would like to see reading of the config file in resolving the credential chain. In my case, it's for automatic role assumption (using role_arn, source_profile, mfa_serial, etc.) via the config file. I have a CLI that I wrote with this module, and I would like for users' credentials to resolve however they would with the AWS CLI.

@jeskew
Copy link
Contributor

jeskew commented Apr 20, 2017

Addressed in #1391.

@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants