Skip to content

Commit

Permalink
fix(NODE-3152): ensure AWS environment variables are applied properly (
Browse files Browse the repository at this point in the history
  • Loading branch information
rose-m committed Apr 6, 2021
1 parent d595634 commit 341a602
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cmap/auth/mongo_credentials.ts
Expand Up @@ -61,16 +61,19 @@ export class MongoCredentials {
this.mechanismProperties = options.mechanismProperties || {};

if (this.mechanism.match(/MONGODB-AWS/i)) {
if (this.username == null && process.env.AWS_ACCESS_KEY_ID) {
if (!this.username && process.env.AWS_ACCESS_KEY_ID) {
this.username = process.env.AWS_ACCESS_KEY_ID;
}

if (this.password == null && process.env.AWS_SECRET_ACCESS_KEY) {
if (!this.password && process.env.AWS_SECRET_ACCESS_KEY) {
this.password = process.env.AWS_SECRET_ACCESS_KEY;
}

if (this.mechanismProperties.AWS_SESSION_TOKEN == null && process.env.AWS_SESSION_TOKEN) {
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
if (!this.mechanismProperties.AWS_SESSION_TOKEN && process.env.AWS_SESSION_TOKEN) {
this.mechanismProperties = {
...this.mechanismProperties,
AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN
};
}
}

Expand Down

0 comments on commit 341a602

Please sign in to comment.