aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

Ini file takes over env variables for specifying credentials

Open rprovodenko opened this issue 3 years ago • 1 comments

Describe the bug

When specifying AWS_PROFILE, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN and AWS_CREDENTIAL_EXPIRATION sdk still uses the ini file for credentials. V2 SDK works fine.

    const sts = new STS({});
    console.log(await sts.getCallerIdentity().promise()); // logs correct user from AWS_PROFILE
    const client = new STSClient({ region: "us-east-1" });
    const command = new GetCallerIdentityCommand();
    console.log(await client.send(command)) // logs incorrect user from the ini file

Must be because of this line: https://github.com/aws/aws-sdk-js-v3/blob/main/packages/credential-provider-node/src/index.ts#L57

Your environment

SDK version number

@aws-sdk/[email protected]

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

Node.js

rprovodenko avatar Nov 26 '21 12:11 rprovodenko

Hi @rostislavdeepcrawl thanks for reaching out. I am able to reproduce your problem. We will investigate this problem more. Also, you can only set AWS_PROFILE or set AWS_ACCSS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN would overwrite the user of AWS_PROFILE.

Getting the correct behavior from JS v2 and CLI v1/v2 that returns the user from AWS_PROFILE.

const sts = new AWS.STS({}); //v2.1044.0
console.log(await sts.getCallerIdentity().promise());
$ AWS_PROFILE=<NAME> AWS STS get-caller-identity

However, for JS v3 SDK:

const command = new GetCallerIdentityCommand();
console.log(await client.send(command)) 

This returns the user from ini file.

vudh1 avatar Dec 08 '21 18:12 vudh1

I'm not able to reproduce this on the latest version, setting to closing-soon.

kuhe avatar Dec 22 '22 15:12 kuhe

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.

github-actions[bot] avatar Jan 10 '23 00:01 github-actions[bot]