MongoDB Atlas VPC peering

0

Hi AWS,

I am deploying a web application backend for testing purpose on Amazon EC2 instance. The instance is inside a VPC. The EC2 and VPC are in us-east-2 Ohio region and the MongoDB Atlas cluster is in us-east-1 N. Virginia region.

The Atlas CIDR (VPC region) is same as Amazon VPC i.e. us-east-2 Ohio. The VPC CIDR is 172.31.0.0/20 and the Atlas VPC CIDR is 192.168.248.0/21.

When I am checking the logs on the EC2 instance I am seeing the error: ERROR [MongooseModule] Unable to connect to the database. Retrying (1)...

The problem is I can't enable the Access from Anywhere option 0.0.0.0/0 assuming if I need to perform the same in production.

Please suggest how to fix this.

profile picture
質問済み 1年前851ビュー
1回答
1

If you are doing VPC peering, you can refer to the security group of the peering destination as shown in the following document.
So try to put a setting in the Mongo DB security group to allow the EC2 security group.
https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-security-groups.html

profile picture
エキスパート
回答済み 1年前
  • Agree.. I have done the exact same before when using VPC peering, you can specifiy a security group from another VPC

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ