Skip to content

Commit 341a602

Browse files
authored
fix(NODE-3152): ensure AWS environment variables are applied properly (#2756)
1 parent d595634 commit 341a602

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/cmap/auth/mongo_credentials.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ export class MongoCredentials {
6161
this.mechanismProperties = options.mechanismProperties || {};
6262

6363
if (this.mechanism.match(/MONGODB-AWS/i)) {
64-
if (this.username == null && process.env.AWS_ACCESS_KEY_ID) {
64+
if (!this.username && process.env.AWS_ACCESS_KEY_ID) {
6565
this.username = process.env.AWS_ACCESS_KEY_ID;
6666
}
6767

68-
if (this.password == null && process.env.AWS_SECRET_ACCESS_KEY) {
68+
if (!this.password && process.env.AWS_SECRET_ACCESS_KEY) {
6969
this.password = process.env.AWS_SECRET_ACCESS_KEY;
7070
}
7171

72-
if (this.mechanismProperties.AWS_SESSION_TOKEN == null && process.env.AWS_SESSION_TOKEN) {
73-
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
72+
if (!this.mechanismProperties.AWS_SESSION_TOKEN && process.env.AWS_SESSION_TOKEN) {
73+
this.mechanismProperties = {
74+
...this.mechanismProperties,
75+
AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN
76+
};
7477
}
7578
}
7679

0 commit comments

Comments
 (0)