0

I have 2 AWS accounts -- we'll call them AWSDev and AWSProd. I also have 2 MongoDB Atlas clusters under a single MongoDB account. I set up a Peer Connection for AWSProd's default VPC and added an entry into the AWSProd Route Table. Works great.

Now I'm setting up the peer connection for AWSDev's default VPC. The peer connection appears to be active, but my Lambda function is unable to connect.

I'm thinking that maybe the issue is that both my AWS VPCs run on the same CIDR block. See the green highlight in the following image: enter image description here

Is this a problem? Will this mean MongoDB Atlas can only communicate with the first one because it's own routing tables can't differentiate between them?

Other things I've done to diagnose:

  1. I ensured the lambda is set up for my default VPC by setting it to run on my VPC's subnets and under the security group.
  2. I verified the mongodb connection string is correct including the user and password.

I'm thinking about creating a new VPC in my AWSDev account and redeploying things to there to see if that resolves it. Any other ideas?

Ben Zuill-Smith
  • 3,504
  • 3
  • 25
  • 44

1 Answers1

1

VPC Peering cannot use CIDR blocks which overlap:

https://docs.aws.amazon.com/vpc/latest/peering/create-vpc-peering-connection.html

It's also not possible to change or modify the IP address range of an existing virtual private cloud (VPC) or subnet. However, you can do one of the following:

-or-

Leeroy Hannigan
  • 11,409
  • 3
  • 14
  • 31
  • okay. This addresses creating a new VPC which I'm considering doing, but would that do anything? Is the problem that both VPCs use the same CIDR block? – Ben Zuill-Smith Dec 29 '22 at 23:56
  • Yes they cannot overlap https://docs.aws.amazon.com/vpc/latest/peering/create-vpc-peering-connection.html – Leeroy Hannigan Dec 30 '22 at 00:11
  • Ah, indeed, a new VPC worked. MongoDB Atlas would have caught my mistake, but I accidentally set up the peer connection with the wrong AWS region on the Atlas side. Thanks for the answer, it gave me more confidence I needed to set up another VPC – Ben Zuill-Smith Dec 30 '22 at 00:58