VPC Peering
Definition
VPC Peering is a networking connection between two Virtual Private Clouds (VPCs) that enables traffic routing between them using private IP addresses. This connection allows resources in different VPCs to communicate as if they were within the same network, without the need for an internet gateway, VPN, or separate physical hardware. VPC Peering is commonly used to facilitate secure and efficient communication between different environments, such as development and production, or between different accounts within the same organization.
Secure Settings Example
resource "aws_vpc_peering_connection" "example" {
vpc_id = "vpc-12345678"
peer_vpc_id = "vpc-87654321"
auto_accept = false
tags = {
Name = "example-vpc-peering"
}
}
resource "aws_vpc_peering_connection_accepter" "example" {
vpc_peering_connection_id = aws_vpc_peering_connection.example.id
auto_accept = false
tags = {
Name = "example-vpc-peering-accepter"
}
}
Insecure Settings Example
resource "aws_vpc_peering_connection" "insecure_example" {
vpc_id = "vpc-12345678"
peer_vpc_id = "vpc-87654321"
auto_accept = true # Automatically accepting peering requests can lead to unauthorized access
tags = {
Name = "insecure-vpc-peering"
}
}