AWS VPC (Virtual Private Cloud) is a service provided by Amazon Web Services (AWS) that allows you to create a virtual network in the cloud. It enables you to define and control a logically isolated section of the AWS cloud where you can launch AWS resources such as EC2 instances, RDS databases, and more.
Here are a few reasons why AWS VPC is essential:
- Isolation and Security
- Custom Networking
- Connectivity Options
- Scalability and Availability
- Compliance and Governance
Overall, AWS VPC is essential because it allows you to create a private, secure, and customizable network environment in the cloud, enabling you to build and deploy your applications with control, flexibility, and scalability.
Let's say you have a fully private RDS and EC2 instance in different VPCs and want to connect from EC2 to RDS. If your EC2 instance and RDS are in the same VPC you can solve this problem with EC2 RDS connection settings. But this is another problem and requires another solution.
An AWS VPC Peer Connection, also known as VPC Peering, is a networking connection between two Virtual Private Clouds (VPCs) in Amazon Web Services (AWS). It allows the VPCs to communicate with each other using private IP addresses as if they were part of the same network.
It's important to note that VPC Peering is not transitive across regions or beyond the peered VPCs. If you need connectivity between multiple VPCs in a hub-and-spoke architecture, you can use a combination of VPC Peering and AWS Transit Gateway.
In summary, VPC Peer Connections provide a simple and secure way to connect VPCs within AWS, enabling seamless communication between resources in different VPCs while maintaining network isolation and control.
First of all, you need to have a peering connection in place. Go to
Peering Connections and create a new connection. Select requester (
VPC A) and accepter (
VPC B) and click Create. Then choose
Accept Request to activate the created connection.
Subnets and check the subnet where your EC2 instance is launched. It should have a route table associated with it.
Add a new record to your Route Table with the target VPC with the CIDR block and select the previously created Peering Connection.
CIDR information of VPC B must be entered into VPC A Subnet. The CIRD information of VPC A must be entered in the VPC B Subnet.
First of all, you need to connect your EC2 instance.
ssh ec2-user@<public-ip> -i ~/.ssh/your-key.pem
Then, you can check the connection with telnet:
telnet db.region.rds.amazonaws.com 5432
In this article, we learned what AWS VPC is, why we should use it, and how to solve problems with VPC Peering. I hope it was useful. See you in the next article. 👻