Komlan Florient dogbe

Apr 2, 2021

5 min read

Create an AWS VPC peering — Application from very zero

In this topic, i will explain from very zero with practice how to create an Amazon AWS vpc peering. it will describe step by step the process for build interconnection that allow vpc resources including EC2 instances that run in different AWS regions.

What is VPC peering ?

Amazon vpc enables you to launch resources into a virtual network. A VPC peering connection is a networking connection between two VPC that enables you to route traffic between them using private IP addresses. Instances in either VPC can communicate with each other as if they are within the same network. You can create a VPC peering connection between your own VPC or another VPC AWS account.

Establish VPC peering relationships between VPC accross different AWS regions. This topic is base on AWS resources including EC2 instances that run in different AWS regions to communicate with each other using private IP address without requiring gateways.

  • Creating a VPC wizard with public and private subnet

Computer resources need external network access to communicate with Amazon EC2 service.However, you might have jobs that you would like to run in private subnets. Creating a VPC with both public and private subnets provides you the flexibility to run jobs in either a public or private subnets. Jobs in a private subnet can access the internet through a NAT gateway.

Creating a VPC wizard follow this step:

  • Run a VPC wizard

Connect to your Amazon AWS account and then choose VPC on amazon services .

In VPC dashboard, launch VPC wizard

Choose VPC with public and private Subnets and then select

Notice that, Elastic IP allocation ID is require for creating VPC. To be private subnet communicate with public subnet, NAT gateway require an elastic ip Address. Create an elastic ip address before running a VPC wizard.

After creating a vpc with respective name, output will be:

  • Create an additional subnets

The wizard create a vpc with a single public and a single private subnet in a single availability zone. For greater availability, you should create at least one more of each subnet type in a different availability zone so that your VPC has both public and private subnet across two availability Zones

In vpc dashboard, choose Subnets and create subnet. this process will be done in both region.

On creating process, choose a vpc that create earlier, and availability zone that’s different with original subnets. Also CIDR block should be in Mumbai region and in Ohio region.

Create private subnet

Create public subnet

  • Create an EC2 instance on both public and private subnet

On creation process, make sure to choose a vpc create earlier and subnet. We are going to create an amazon linux 2 instance.

  • Test connectivity

After creating an ec2 instance in different subnet and vpc, we will use ping command to test connectivity between each host.

Test connectivity in Mumbai Region

Host in Private subnet is reachable by Public subnet in Mumbai region

Test connectivity between different region(Mumbai-Ohio)

Noticed that Host in another region is not reachable.

  • Create a VPC Peering

Creating a VPC peering connection with a vpc in different region. Follow step below :

In your Amazon navigation pane, choose peering connection and then Create peering connection.

Make sure to choose Another region for Ohio, Go to this region and copy a VPC ID and paste in VPC ID(accepter) option. Then create a vpc peering.

Creation process is done with status still pending:

To be vpc peering status update to accepted, go to Ohio region navigation pane and choose peering connection.

Select vpc peering connecting that appear and choose action ,then accept Request.In the confirmation dialog display, choose Yes Accept.

Output will be:

Activating peering connection not guarantees, connection is set between two region. 😕 😟

To be any instance is subnet1 connect to subnet2 in another region, we have to update a routing table.Means to add subnet address in both vpc routing table.

Go to vpc dashboard -> choose Vpc ID -> main route table ->Edit route

Now configuration is set up successfully!!!!!!!!!!!!!

We can test connectivity between these two instance base in different region

Connection is set successfully!!!!!!!!!!!!!!!! 😃 😄 ✌️

Thanks for your interesting and ready, in my new topic i will continuous with another application of using s3 and RDS.