DEV Community

Cover image for Why Use Multiple VPCs Instead of One?
Ijay
Ijay

Posted on

Why Use Multiple VPCs Instead of One?

When I started learning AWS networking, I thought creating private subnets was enough for security.

Then I noticed something:
People still create multiple VPCs.

That made me curious.

Why not just use one VPC?

Imagine this setup:

  • A web server that users need to access
  • A database that should remain private

The web server may need to be public so users can reach the application through the internet.

But exposing the database publicly would be risky.

So instead of placing everything inside one VPC, AWS allows you create multiple VPCs for better isolation.

Example:

  • VPC 1 can contain the web server
  • VPC 2 can contain the database

So how do both VPCs communicate?

This is where VPC Peering comes in.

VPC Peering is a feature that privately connects two VPCs.

Resources inside both VPCs can communicate using private IP addresses without passing traffic through the internet.

That means:

  • The web server can still access the database
  • The database remains private
  • communication stays within AWS private networking

One important thing I learned

The VPC CIDR blocks must not overlap.

For example:

  • VPC 1 → 10.0.0.0/16
  • VPC 2 → 10.1.0.0/16

This works.

But if both VPCs use the same CIDR range, the peering connection will not work properly.

VPC peering


Other Resources

If you found this article helpful, feel free to share it. And if you prefer learning through videos, I also explain cloud topics in simple terms on my YouTube channel.

Stay updated with my projects by following me on Twitter, LinkedIn, and GitHub.

Thank you for reading!

Top comments (0)