in packages/aws-rfdk/lib/lambdas/nodejs/mongodb/handler.ts [53:80]
public async doCreate(physicalId: string, resourceProperties: IMongoDbConfigureResource): Promise<object|undefined> {
const mongoDbDriver = this.installMongoDbDriver();
const mongoClient = await this.mongoLogin(mongoDbDriver, resourceProperties.Connection);
try {
if (resourceProperties.PasswordAuthUsers) {
const adminDb = mongoClient.db('admin');
for (const userArn of resourceProperties.PasswordAuthUsers) {
if (!await this.createPasswordAuthUser(adminDb, userArn)) {
// Note: Intentionally not including the data as part of this message. It may contain secrets, and including it will leak those secrets.
console.log(`User in '${userArn}' already exists in the MongoDB. No action performed for this user.`);
}
}
}
if (resourceProperties.X509AuthUsers) {
const externalDb = mongoClient.db('$external');
for (const x509User of resourceProperties.X509AuthUsers) {
if (!await this.createX509AuthUser(externalDb, x509User)) {
// Note: Intentionally not including the data as part of this message. It may contain secrets, and including it will leak those secrets.
console.log(`User in '${x509User.Certificate}' already exists in the MongoDB. No action performed for this user.`);
}
}
}
} finally {
console.log('Closing Mongo connection');
await mongoClient.close();
}
return undefined;
}