How to securely connect AWS elastic beanstalk to MongoDB Atlas.
As you may know, elastic beanstalk doesn’t have a static IP. So one of the options is to add a NAT Gateway to AWS and this should give us a static IP that we can whitelist in Atlas.
But is this the best approach?
What about VPC peering? Does it work seamlessly?
If yes, do we need NAT Gateway in AWS to make VPC peering possible?
Is there any tutorial that best describes for to do this peering?
You can create the beanstalk(s) inside your AWS VPC and then configure a VPC peering connection to Atlas. Just ensure you have a route table entry which routes the traffic from the application(s) to the Atlas VPC’s CIDR (destination) via the peering connection (target). You can whitelist the security group ID’s associated with your beanstalk application(s) or your AWS VPC CIDR range which is peered to Atlas.
I believe most of the configuration for this particular set up would need to be done on the AWS end outside of setting up the peering connection between your AWS VPC and the Atlas project.