I followed the AWS quick start guide for creating a MongoDB cluster. This created a NAT instance (Public subnet), as well as one instance of PrimaryReplicaNode (internal IP address only). I can use SSH in NAT and, in addition, I can use SSH in Primary Replica from NAT. I checked that MongoDB is accessible from the command line, but I need to go through two servers to get there.
On the other hand, I made a quick start node.js server on Elastic Beanstalk. I also put it in the same VPCs and security groups as NAT.
So, I have 3 shared instances. 1 Elastic Beanstalk instance running node and 2 EC2 instances working as a MongoDB cluster.
My question is ... how to connect to MongoDB from the Elastic Beanstalk app?
Should I provide Elastic Beanstalk with the same key that I gave NAT so that it can access the internal Primary node? Or am I connecting to an external NAT address from node.js and then tunneling into a cluster? What exactly needs to be connected in order to ensure its implementation?
Any advice would be highly appreciated!
source share