I am setting up a deployment for my company's API Server and it fails to connect to MongoAtlas via IAM role
What I've done:
- Set up a IAM Role on AWS (APIServer)
- Set up a Database User on Atlas with the role (arn:aws:iam::< my aws acc id >:role/APIServer)
- Configure a launch template and an auto scaling group, launching Amazon Linux EC2 instances with the role
- Have my NodeJS application connect to my Atlas with the following setting:
| key | value |
|---|---|
| URL | mongodb+srv://dev.< cluster >.mongodb.net/< DB > |
| authSource | '$external' |
| authMechanism | 'MONGODB-AWS' |
I ended up receiving the following error message
MongoServerError: bad auth : user arn:aws:sts::<my aws acc id>:assumed-role/APIServer/* is not found
Note: the info enclosed in <> are intentionally replaced, since I have already found several solutions pointing out having <> as part of the password, which is not my case here