I am trying to implement MongoDB Client-side Field level encryption inside aws lambda function. Getting an error
MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27020
I am trying to create a secure connection as below
const keyVaultNamespace = "{Collection-name}.__keyVault";
const tmpPath = path.resolve(process.env.LAMBDA_TASK_ROOT, "../../tmp");
process.env.LD_LIBRARY_PATH = `${process.env.LD_LIBRARY_PATH}:${process.env.LAMBDA_TASK_ROOT}/lib`;
this.secureClient = new MongoClient(`{Mongo atlas URI}`, {
useNewUrlParser: true,
useUnifiedTopology: true,
autoEncryption: {
keyVaultNamespace,
kmsProviders,
schemaMap: accountsSchema,
extraOptions: {
mongocryptdSpawnArgs: [`--pidfilepath=${tmpPath}/mongocryptd.pid`],
mongocryptdSpawnPath: `${process.env.LAMBDA_TASK_ROOT}/bin/mongocryptd`,
}
},
});
await this.secureClient.connect();
I am trying to connect to my MongoDB Atlas.