We are using IAM auth to authenticate our lambda functions with Atlas. Due to security and compliance restrictions we need the lambda to perform an SSM call to assume the role that is added in Atlas as a DB user.
This works fine, but the SSM session is valid for one hour only. Sometimes we have hot lambdas, where the execution context is older than one hour, which results in an authentication error.
My question is: Currently the MongoDB node driver does not refresh the ssm session. Is this planned? If not: How can I catch the auth error on the client side in the driver to reconnect with fresh credentials? I tried adding the following event, but the data is never logged / the event handler never called:
client.on(“error”, async (e) => {
console.error(‘this.client.on(“error”’, e);
})