I followed the AWS quickstart guide for creating a MongoDB cluster. This created a NAT Instance (Public subnet) as well as a single PrimaryReplicaNode instance (internal IP only). I can SSH into the NAT and furthermore, I can SSH into the Primary Replica from the NAT. I've verified that MongoDB is accessible from the command line, but I have to get "through" two servers to get there.
On the other hand, I did a quickstart node.js server on Elastic Beanstalk. I also placed it within the same VPC and security groups as the NAT.
So I've got 3 total instances. 1 Elastic Beanstalk instance running node and 2 EC2 instances running as a MongoDB cluster.
My question is... how do I connect into MongoDB from the Elastic Beanstalk application?
Do I need to give Elastic Beanstalk the same key that I gave the NAT so it could access the internal Primary node? Or do I connect to the NAT's external address from Node.js and then tunnel into the cluster? What exactly needs to connect to what in order to make it serve its purpose?
Any advice would be much appreciated!