How to securely connect AWS elastic beanstalk to MongoDB Atlas

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?

Hi @Mazen_Hilal - Welcome to the MongoDB Community! :slight_smile:

What about VPC peering? Does it work seamlessly?

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.

Hope this helps.

Best Regards,
Jason

1 Like

Great. Thank you Jason for your swift reply

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.