edasque / DynamoDBtoCSV

Dump DynamoDB data into a CSV file
Apache License 2.0
471 stars 152 forks source link

[Bug] Profile aren't properly handled, return wrong credentials #56

Closed Vadorequest closed 5 years ago

Vadorequest commented 5 years ago

I won't make a PR because those existing seem dead and don't want to waste my time, but know that the profile isn't correctly managed as it is now.

Current version (buggy):

if (program.profile) {
  var newCreds = AWS.config.credentials;
  newCreds.profile = program.profile;
  AWS.config.update({ credentials: newCreds });
}

This doesn't work as expected, it doesn't select the credentials for the right profile but from the first defined profile. It may have worked with a very simple setup (1 profile) but doesn't really handle multi profiles.


Fixed version:

if (program.profile) {
  var newCreds = new AWS.SharedIniFileCredentials({ profile: program.profile });
  newCreds.profile = program.profile;
  AWS.config.update({ credentials: newCreds });
}

See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html

edasque commented 5 years ago

Thank you, done.

Vadorequest commented 5 years ago

Whoa, that was fast. Thanks!