How to connect to mongo db from different aws region?

Hello, folks!

I need to connect my service from another AWS region into my MongoDB Atlas Cluster.

Using Private Link, how is this possible?

Scenario:
- Application in us-east-2.
- Mongo DB Atlas cluster in us-east-1.

If I just create a Private Link in us-east-2, will it work?
Or do I need to maintain VPC compatibility between us-east-1 (MongoDB) and us-east-2 (Application)? What is the best approach?

Note: In the future the application will be migrated to us-east-1.

Hi @Leonardo_Augusto_Gallo - Welcome to the community :wave:

From the Set Up a Private Endpoint documentation:

  • To connect to Atlas database deployments using AWS PrivateLink from regions in which you haven’t deployed a private endpoint connection, you must peer VPCs in those regions to VPCs in a region in which you have deployed a private endpoint connection.To learn about inter-region VPC peering, see the AWS documentation.

I believe in your particular example based off the information provided, you’ll need to set up a VPC in Region us-east-1 and have the private link and private endpoint associated with the Atlas connection in this VPC.

You would then need to set up VPC peering between your 2 VPC’s (Your AWS VPC us-east-1 ← VPC peering → Your AWS VPC us-east-2). Essentially the connection / traffic from your Application in us-east-2 would go through the VPC peering to your VPC in region us-east-1 which would then go via the private endpoint / private link to the Atlas cluster in us-east-1.

In saying the above, since you’ll move the application to us-east-1 eventually, you would then no longer need us-east-2 VPC or the inter-region VPC peering connection when this happens assuming nothing else changes.

Hope this helps and let us know if you require any further help from the MongoDB Atlas side.

Regards,
Jason

1 Like

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