💻Demo On VPC Peer Connection Between 2 EC2 Instances in AWS 🚀

DV RAHULDV RAHUL
4 min read

👋🏻 INTRODUCTION :

VPC (virtual private cloud):

It is a virtual network dedicated to your AWS account . It provides a logically isolated region of the AWS cloud where you can launch your resources and configure network settings.

Subnet : It is a segmented portion of larger network such as vpc and where you can place and organise resources. There are 2 types of subnets private , public.

Route table : it is a set of rules or routes that determines where network traffic is directed.

🪜LEARNING OUTCOMES STEPWISE :

💻Step 1: Creating 2 VPC's

💻Step 2: Creating 2 Subnet's

💻Step 3: Creating Peer connection's

💻Step 4: Creating 2 Internet Gateway's

💻Step 5: Creating 2 EC2 Instances

💻Step 6: Connecting instances

💻Step 7: Editing inbound Rules in Security groups

💻Step 8: Editing Routes in Route Tables

💻Step 9: Result

💻Step 10 : Termination

🚀🪜 steps were noted as climbing a ladder🪜

💻Step 1: Creating 2 VPC's : Place the ladder

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

step 1.1 : Creating first vpc

🪜Go to AWS console search for VPC

🪜 Click on "Create VPC"

🪜 Name the VPC as "vpcdemo-1"

⭐ IP address for "vpcdemo-1" is 10.2.0.0/16

🪜Click on create vpc , Hence "vpcdemo-1" created

step 1.2 : creating Second vpc

🪜Follow the same and create your second vpc named "vpcdemo-2"

⭐ "IP address" for vpcdemo-2 is 10.3.0.0/16

🪜Click on create vpc , Hence vpcdemo-2 created

🪜 First step successfully completed

💻Step 2: Creating 2 Subnet's : Start climbing

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

step 2.1: Creating first subnet with "vpcdemo-1"

🪜 Duplicate the window and search subnet

🪜Create a subnet , Select "vpcdemo-1"

🪜 Give ipv4 for "subnetdemo-1" : 10.2.0.0/24

🪜"Subnetdemo1" created

step 2.2: creating second subnet with "vpcdemo-2"

🪜Create a subnet , Select "vpcdemo-2"

🪜 Give ipv4 for "subnetdemo-1" : 10.3.0.0/24

🪜"Subnetdemo2" created

🪜Two subnets created

💻Step 3: Creating Peer connection's : Go ahead

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

🪜Duplicate the tab and open peer connections in vpc

🪜Creating peer connection , name it as "vpcpeerdemo" , select vpcdemo-1 as a Requester

🪜Select vpcdemo-2 as a "accepter"

🪜Status is pending , Now accept the request .

🪜Now status is "active"

💻Step 4: Creating 2 Internet Gateway's : Time to take break

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

step 4.1 : Duplicate the tab and create first internet gate way

🪜create internet gate way "igdemo1"

🪜Attach igdemo1 to "vpcdemo1"

step 4.2 : Create Second internet gate way in the same process

💻Step 5: Creating EC2 Instances : Its time to pack again

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

step 5.1 : Creating first ec2 instance "ec2demo-1"

🪜Select any existed key pair , or else click on create

🪜Click on edit , Create a security group named "sgdemo-1" make sure to connect vpcdemo-1 , subnetdemo-1

🪜 Provide code in advanced settings

🪜Ec2 instance created successfully

step 5.2 : Creating first ec2 instance "ec2demo-2" , in the same process :

💻Step 6: Connecting instances : continue

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

🪜 select ec2demo-1 click connect Copy private Ip address

🪜 select "ec2demo-2" click connect

🪜 It Displays failed to connect

💻Step 7: Editing inbound Rules in Security groups : climb

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

🪜Edit inbound Rules in sgdemo1

🪜Select All Traffic , Anywhere IP4

🪜Edit inbound Rules in "sgdemo2" in the same way

💻Step 8: Editing Routes in Route Tables : Almost reached

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

🪜Naming Route table 1

copy vpcdemo1 id

🪜 Search Route table with "vpcdemo-1" id Name it as "routetable-1"

🪜Search Route table with "vpcdemo-2" id Name it as "routetable-2"

🪜Adding Routes

🪜Give IP address for "vpcdemo-1" is 10.2.0.0/16 , Choose peer connections , internet gate way

🪜Give IP address for "vpcdemo-2" is 10.3.0.0/16 , Choose peer connections , internet gate way

💻Step 9 : Result : Reached

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

🪜Refresh the instances

🪜Give private ip address of "ec2demo-1" to "ec2demo-2"

🪜Give private ip address of "ec2demo-1" to "ec2demo-2"

🪜Hence connection established

💻Step 10 : Termination : back to home

🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶🚶

Terminate step wise:

  1. Terminate Both the instances

  2. Delete peer connection

  3. Delete Subnets

  4. Delete VPC's

  5. internet gateways gets automatically deleted

🔚Conclusion:

The purpose of this lab was to demonstrate the configuration and connection setup of Virtual Private Cloud (VPC) components in AWS, showcasing the fundamental concepts such as VPCs, Subnets, Route Tables, Internet Gateways, and EC2 instances.

20
Subscribe to my newsletter

Read articles from DV RAHUL directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

DV RAHUL
DV RAHUL