DEV Community

Cover image for Building a Globally Connected Network: A Step-by-Step Guide to VPCs, Internet Gateway, and VPC Peering in AWS
Shamim Ansari
Shamim Ansari

Posted on

Building a Globally Connected Network: A Step-by-Step Guide to VPCs, Internet Gateway, and VPC Peering in AWS

Creating a Virtual Private Cloud (VPC) in AWS and setting up VPC peering between two regions can be a bit complex for beginners, but I'll provide a step-by-step guide to help you through the process. VPC peering allows you to connect VPCs in different regions as if they were on the same network. Here's a simplified guide:

Step 1: Log in to the AWS Console

Step 2: Choose the First Region

  • In the AWS Management Console, make sure you're in the region where you want to create the first VPC.

Step 3: Create the First VPC and Internet Gateway
Go to the VPC Dashboard:

  • In the AWS Management Console, navigate to the "Services" menu.
  • Select "VPC" under the "Networking & Content Delivery" section.
  • Click "Your VPCs" in the left-hand navigation pane.
  • Click "Create VPC."

Fill out the form for the first VPC:

  • VPC Name: Give your VPC a name (e.g., MyVPC).
  • IPv4 CIDR Block: Define the IP address range for your VPC (e.g., 10.0.0.0/16).
  • IPv6 CIDR Block: You can leave this blank for now.
  • Tenancy: Choose "Default."
  • Click "Create VPC."

  • In the VPC Dashboard, go to "Internet Gateways."

  • Click "Create Internet Gateway" and give it a name (e.g., MyIGW).

  • Select the Internet Gateway you just created and click "Attach to VPC." Choose the VPC you created.

Step 4: Create Subnets
After creating the VPC, go to "Subnets" in the VPC Dashboard.

  • Click "Create Subnet."

Fill out the form for each subnet:

  • Name tag: Give it a name (e.g., Subnet-1).
  • VPC: Choose the VPC you created.
  • Availability Zone: Choose an availability zone.
  • IPv4 CIDR Block: Define the subnet's IP address range (e.g., 10.0.1.0/24).
  • Repeat this process for each subnet you want to create.

Step 5: Set Up Route Tables and Internet Gateway

Go to "Route Tables" in the VPC Dashboard.

  • Create a route table for each subnet and associate it with the appropriate VPC.

  • Define the routes for each route table. For the public subnet, add a route to the Internet Gateway.

Step 6: Choose the Second Region

In the AWS Management Console, change your region to the one where you want to create the second VPC.

Step 7: Create the Second VPC and Internet Gateway

Note: Follow the same steps as in "Step 3" to create a VPC in the second region.

In the VPC Dashboard, go to "Internet Gateways."

  • Click "Create Internet Gateway" and give it a name (e.g., MyIGW).

  • Select the Internet Gateway you just created and click "Attach to VPC." Choose the VPC from the second region.

Step 8: Set Up VPC Peering

  • In the second region, go to "VPC Peering Connections" in the VPC Dashboard.

  • Click "Create Peering Connection."

Fill out the form:

  • Peering Connection Name: Give it a name (e.g., MyPeeringConnection).
  • Your VPC: Choose the VPC from the second region.
  • Peer VPC: Choose the VPC from the first region.
  • Click "Create Peering Connection."

Step 9: Accept Peering Request

  • In the second region, select the peering connection and click "Actions."

  • Choose "Accept Request."

Step 10: Configure Route Tables for Peering

  • In both regions, update your route tables to allow traffic from the peered VPC.

That's it! You've created VPCs in two different regions, set up VPC peering, and configured an Internet Gateway for the public subnet to enable internet access from the VPCs. Be mindful of security group and network ACL rules to control the traffic.

Follow me on Linkedin | Twitter for more such contents

Top comments (0)