I have a Ruby script that connects to MongoDB Atlas for getting some data. It does work perfectly if I:
However it doesn't work inside kubernetes, I am using EKS.
I have tried all items listed before and make sure the user exists on MongoDB Atlas.
This is pretty much the output that I receive:
User moon (mechanism: scram) is not authorized to access test (used mechanism: SCRAM-SHA-1) (Mongo::Auth::Unauthorized)
I'd appreciate any input.
What i have found:
It looks like users permissions miss configuration:
As per documentation: Create a MongoDB User for Your Cluster.
You must create a MongoDB user to access your deployment. For security purposes, Atlas requires clients to authenticate as MongoDB users to access clusters.
MongoDB users are separate from Atlas users:
MongoDB users can access databases hosted in Atlas. Atlas users can log into Atlas but do not have access to MongoDB databases.
Hope this help.
Solved by adding &authSource=admin
to the connection string.