DEV Community

Cover image for How to Set Up AWS VPC Peering for Private Connectivity - Effortlessly
Mubbashir Mustafa for Rebase

Posted on • Edited on

How to Set Up AWS VPC Peering for Private Connectivity - Effortlessly

👉🏽 Try Rebase for free, no credit card needed

If you work with multiple VPCs in AWS, sooner or later you’ll want them to talk to each other. Sometimes you split workloads into different VPCs to keep things separate, or your team is working across different AWS accounts. AWS lets you connect those VPCs with something called VPC peering. That way, the traffic stays private, never hitting the public internet. But if you’ve ever tried to set this up by hand, you know it can be a hassle. You have to make sure the CIDR blocks do not overlap, the route tables are right, and both sides accept the connection. Missing one step means your setup just doesn’t work.

With Rebase, you can do all of this just by telling the agent what you want. Here’s how it works from start to finish.

We’ll start by spinning up two VPCs, both with private subnets and non-overlapping CIDR blocks. This is important, because VPC peering won’t work if the address ranges clash.

This screenshot shows two separate VPCs with their own private subnets and unique CIDR blocks. The network diagrams are side by side.

The AI agent will put together a plan and show you exactly what it’s about to do. If it needs more info, it’ll ask before moving ahead.

Here, the agent prompts for any extra details it needs to finish building the plan, like subnet ranges or region.

Once you answer, the agent finalizes the plan for you.

This step displays the full breakdown of what’s going to be created in AWS.

The agent asks for a quick confirmation to make sure everything looks right.

The agent displays a confirmation message, waiting for your approval.

After you confirm, the agent goes ahead and provisions everything.

The UI shows that resources are being created and progress updates as it moves through the steps.

When it’s done, you’ll get a summary of everything it created. You can see all the details here.

Summary screen with the new VPC IDs, subnets, and other details.

Now grab those VPC and subnet IDs. Let’s try connecting to an EC2 instance in one of these VPCs using AWS SSM (Session Manager).

Here, the screenshot highlights EC2 instance details, showing where to find instance IDs and SSM status.

When you tell the agent you want to access EC2 via SSM, it will ask for confirmation and take care of the setup.

The UI confirms that it’s about to set up the IAM permissions and any prerequisites needed for SSM.

After it’s done, it will let you know that everything is set up and ready.

Screenshot shows SSM access has been configured successfully.

You’ll see the exact commands you need to connect through AWS SSM.

Screen with copy-paste ready commands to connect to your EC2 instances using SSM.

If you hit any errors, just tell the agent and it will troubleshoot and fix things for you.

Screenshot shows the agent working through and resolving a user-reported problem.

It’ll walk you through any follow-up steps if you need more help.

Agent is showing additional instructions or info on the screen.

Another example of the agent breaking things down for you.

Now, grab the private IPs of both instances in each VPC. You’ll need them for the next step.

The EC2 dashboard displays private IP addresses for each running instance.

If you’re not sure how to test the setup, just ask the agent and it’ll help out.

Screen displays suggested ways to check connectivity, like ping commands.

When you log in with SSM and try to ping the other instance from the first one, it won’t work yet. That’s because VPC peering isn’t enabled.

Screenshot shows a ping command timing out, showing the two VPCs are not connected yet.

Now, let the agent know you want to enable VPC peering. It will handle everything needed for that.

Screen shows the agent starting the VPC peering setup.

The agent figures out all the steps, including updating route tables, so traffic can flow between the VPCs.

Here, it shows the agent updating routes and confirming peering is enabled.

If there’s anything else needed, the agent will suggest it and ask for your go-ahead.

Screenshot with a confirmation prompt for additional changes.

When it’s all done, you’ll get a summary of what was changed.

Screen shows a summary of the peering connection and updated route tables.

If you want to double-check, you can confirm everything from the AWS console.

Here’s the VPCs:

Screenshot shows the AWS VPC dashboard with both VPCs and the peering connection.

And here’s the EC2 instances:

EC2 dashboard with both instances running in separate VPCs.

Now, if you try pinging from one EC2 instance to the other over their private IPs, it works. You’re all set.

Screenshot shows a successful ping from one instance to the other after peering is complete.

That’s it. VPC peering, start to finish, without having to mess with the AWS console or memorize all the steps.

Top comments (0)