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

Cannot get credentials using credential_process in config file #3156

Closed
TheRyanBurke opened this issue Mar 17, 2020 · 2 comments
Closed

Cannot get credentials using credential_process in config file #3156

TheRyanBurke opened this issue Mar 17, 2020 · 2 comments
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@TheRyanBurke
Copy link

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Cannot create AWS client with credentials from credential_process that is defined in ~/.aws/config file. Error returned is:

CredentialsError: Could not load credentials from SharedIniFileCredentials
    at SharedIniFileCredentials.load (/Users/burkery/projects/aws-js-sdk-w-credentialprocess/node_modules/aws-sdk/lib/credentials/shared_ini_file_credentials.js:144:11)
...
{
  message: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1',
  code: 'CredentialsError',
  time: 2020-03-17T18:55:28.129Z,
  originalError: {
    message: 'Could not load credentials from SharedIniFileCredentials',
    code: 'CredentialsError',
    time: 2020-03-17T18:55:28.129Z,
    originalError: {
      message: 'Credentials not set for profile dev',
      code: 'SharedIniFileCredentialsProviderFailure',
      time: 2020-03-17T18:55:28.128Z
    }
  }
}

config file has profile like:

[profile dev]
region = us-west-2
account = redacted
role = redacted
credential_process = redacted

Environment variable AWS_SDK_LOAD_CONFIG is set to 1 (validated from node.js code).

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v12.16.1

SDK version number
v2.640.0

To Reproduce (observed behavior)
From terminal:

$ export AWS_SDK_LOAD_CONFIG=1
$ node index.js

Config file:

[profile dev]
region = us-west-2
account = redacted
role = redacted
credential_process = redacted

A file exists at ~/.aws/credentials but has no profile specified for 'dev'.

index.js:

const aws = require('aws-sdk')

const credentials = new aws.SharedIniFileCredentials({profile: 'dev'});
aws.config.update({region: 'us-west-2'});
aws.config.credentials = credentials;

aws.config.getCredentials(function(err) {
  if (err) console.log(err.stack);
  // credentials not loaded
  else {
    console.log("Access key:", aws.config.credentials.accessKeyId);
    console.log("Secret access key:", aws.config.credentials.secretAccessKey);
  }
});

Expected behavior
Expect AWS SDK to fetch credentials from the credential_process specified in the .aws/config file. Support for this path was merged in PR #2559

Additional context
Originally trying to use AWS CDK with credential_process and landed on this issue: aws/aws-cdk#3008 Saw the PR in aws-sdk-js that merged in credential_process support and wanted to test out a basic nodejs app attempting to use credential_process first.

@TheRyanBurke TheRyanBurke added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 17, 2020
@ajredniwja
Copy link
Contributor

Hey @TheRyanBurke thank-you for reaching out, can you try and remove the profile prefix?

Can you also share the code that you are using for your use case?

@ajredniwja ajredniwja added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. closing-soon This issue will automatically close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 18, 2020
@lock
Copy link

lock bot commented Apr 4, 2020

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 Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants