Skip to content

AWS.SharedIniFileCredentials loadRoleProfile using non existent options #2197

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
dpmallinger opened this issue Aug 14, 2018 · 4 comments
Closed
Assignees
Labels
closed-for-staleness feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release

Comments

@dpmallinger
Copy link

this code:
var sourceCredentials = new AWS.SharedIniFileCredentials(
AWS.util.merge(this.options || {}, {
profile: sourceProfileName,
preferStaticCredentials: true
})
);

is broken because this.options is null because its not saved in the constructor. This causes filename to be null and thus the code defaults to ~/.aws/credentials instead of process.env.AWS_SHARED_CREDENTIALS_FILE ( or whatever was passed into the original constructor call)

In addition; the constructor filename does not default per the documentation.
this.filename = options.filename
should be
this.filename = options.filename || process.env.AWS_SHARED_CREDENTIALS_FILE
to match this documentation:

  • @option options filename [String] ('~/.aws/credentials' or defined by
  • AWS_SHARED_CREDENTIALS_FILE process env var)
  • the filename to use when loading credentials.
dpmallinger pushed a commit to dpmallinger/aws-sdk-js that referenced this issue Aug 14, 2018
aws#2197

updated the constructor to save this.options
updated the constructor to honor process.env.AWS_SHARED_CREDENTIALS_FILE
@chrisradek
Copy link
Contributor

@dpmallinger
The behavior you're seeing is expected. In order to maintain backwards-compatibility for users that use more than one SDK/tool, when we added support for the AWS_SHARED_CREDENTIALS_FILE, we put it behind the AWS_SDK_LOAD_CONFIG environment variable. See here for more info on that change.

This is absolutely something we are changing when we do a major version bump, but couldn't be done at the time we added it without potentially breaking users.

@dpmallinger
Copy link
Author

dpmallinger commented Aug 14, 2018

@chrisradek
I updated the pull request to just be the fix for this.options

if I don't have any env vars set and I call
const profileCredentials = new AWS.SharedIniFileCredentials({filename:'/foo/bar/baz'});
the filename is lost in loadRoleProfile(). I feel that fix is still valid and needed.

@srchase srchase assigned srchase and chrisradek and unassigned srchase and chrisradek Aug 14, 2018
@srchase srchase added feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release labels Nov 15, 2018
@sturdiva
Copy link

+1 to this, We are also unable to use credentials across assumeRole calls with a non-standard credential file due to the options variable not being saved in the constructor.

    var credentials = new AWS.SharedIniFileCredentials ({
        'filename': '/path/to/credentials',
        'profile':  'remote-role',
    });

    AWS.config.credentials = credentials;
[static-role]
aws_access_key_id = AK1234
aws_secret_access_key = secret

[remote-role]
role_arn = arn:aws:iam::123456789012:role/foo
source_profile = static-role

@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Feb 25, 2021
@github-actions github-actions bot closed this as completed Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release
Projects
None yet
Development

No branches or pull requests

5 participants