Skip to content

Not loading creds from Shared Credentials File #2289

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
jaisrael1 opened this issue Oct 3, 2018 · 6 comments
Closed

Not loading creds from Shared Credentials File #2289

jaisrael1 opened this issue Oct 3, 2018 · 6 comments
Labels
guidance Question that needs advice or information.

Comments

@jaisrael1
Copy link

jaisrael1 commented Oct 3, 2018

I am using Windows 10 and Windows Subsystem for Linux (WSL). In order to keep my AWS credentials centralized, I have the AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE environment variables in Windows set to the location of ~/.aws/config and ~/.aws/credentials in the Linux file system. I have also set AWS_PROFILE to the profile I would like to use.

When I run 'aws configure list' from cmd, it retrieves them just as I would expect. It gives the same output as when I run the command in the Linux subsystem except that the location of config-file is

\Users\Jake\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\jaisrael.aws\config

Rather than

~/.aws/config

The keys it gets are correct. When I check AWS.config.credentials from within a nodejs script however, it comes up as 'null'. I expected it to load credentials from the config and credentials files just as the CLI does.

@srchase
Copy link
Contributor

srchase commented Oct 3, 2018

Hello @jaisrael1

Thanks for reporting this issue.

Is AWS_PROFILE being properly loaded in the nodejs script?

To make sure I'm understanding this fully, which command is giving you these paths?

\Users\Jake\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\jaisrael.aws\config

@srchase srchase added Question closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 3, 2018
@jaisrael1
Copy link
Author

jaisrael1 commented Oct 3, 2018

All 3 environment variables are being properly loaded in the script.

When I type 'aws configure list' in cmd, it prints:

Name Value Type Location
---- ----- ---- --------
profile MFAProfile manual --profile
access_key [MYKEY] shared-credentials-file
secret_key [MYSECRET] shared-credentials-file
region us-east-1 config-file \Users\Jake\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\jaisrael\.aws\config

So that path is the location of the config file that the region is being loaded from. It is stored in the AWS_CONFIG_FILE environment variable.

I found a workaround, I can manually set 'AWS.config.credentials = new AWS.SharedIniFileCredentials({ filename: process.env.AWS_SHARED_CREDENTIALS_FILE});'

As long as I put 'const S3 = new AWS.S3()' after the above line, everything works.

So because I can load the creds from the shared credentials file manually and everything appears to work, it looks like it's just not doing this automatically.

@no-response no-response bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 3, 2018
@srchase srchase added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 4, 2018
@srchase
Copy link
Contributor

srchase commented Oct 4, 2018

@jaisrael1

Have you set AWS_SDK_LOAD_CONFIG?

That needs to be set for the shared credentials file to be loaded.

See this PR for details: #1391 (comment) with additional context here: #2197 (comment)

@jaisrael1
Copy link
Author

That fixed the problem, many thanks!

@no-response no-response bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 4, 2018
@srchase
Copy link
Contributor

srchase commented Oct 4, 2018

You're welcome! Closing this issue.

@srchase srchase closed this as completed Oct 4, 2018
@srchase srchase added guidance Question that needs advice or information. and removed Question labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 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 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants