Right now have a VPC where is my RDS in a private subnet, also I have a ECS in the same VPC and both have communication, now the problem is that I have a new ECS but in another VPC, first I tried to do a VPC peering, but bot VPC have the CIDR overlapping. What can I do?
I expect to have a solution for my problem
2
Answers
You could use AWS Transit Gateway. This will allow you to connect multiple VPCs through a single gateway and will help route traffic between VPCs without the need for overlapping CIDR blocks.
Here are detailed steps on how you could do it:
Create a Transit Gateway (VPC dashboard, select Transit Gateway and then create)
Attach VPCs (Select create transit gateway attachment and choose the VPC and respective subnets)
Configure Route Tables (Update the route tables to include a route to the Transit Gateway)
Update Security Groups (Ensure the security groups associated with your ECS tasks and RDS instances allow traffic from the CIDR blocks of the respective VPCs)
This is the most straightforward and scalable solution for connecting multiple VPCs without overlapping CIDR blocks.
You can’t peer overlapping VPCs. You can create attachments to a Transit Gateway for overlapping VPCs, BUT it will not let you propagate two identical CIDRs, and only the first route is propagated so it’s not routable.
The easiest way around this (without faffing with S2S VPNS + NATs or AWS Private NAT GW + TGW) is using AWS Private Link. It is useful for Producer/Consumer architectures and is compatible with over-lapping CIDRs as it uses VPC Endpoints.
Here is more info: https://docs.aws.amazon.com/vpc/latest/privatelink/create-endpoint-service.html