Building a Globally Connected Network: A Step-by-Step Guide to VPCs, Internet Gateway, and VPC Peering in AWS
Tags: aws, beginners, opensource, devops
Published: 2023-11-09 15:28:57

## 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**
- Go to the AWS Management Console (https://aws.amazon.com/).
- Sign in with your AWS account credentials.

**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](https://www.linkedin.com/in/shamim-ansari7/) | [Twitter](https://twitter.com/shamim_faizi786) for more such contents