Skip to main content

🌐 05. VPC Flow Logs & VPC Peering (AWS)

In this lecture, we cover two important VPC features:

  • VPC Flow Logs β€” for monitoring and troubleshooting network traffic.
  • VPC Peering β€” for private connectivity between VPCs.

1. VPC Flow Logs​

VPC Flow Logs capture information about the IP traffic going to and from network interfaces within your VPC.

They help you:

  • Diagnose connectivity issues.
  • Analyze traffic patterns.
  • Audit and monitor network access.

βš™οΈ Scope Levels​


You can create flow logs at multiple levels:

LevelDescription
VPCCaptures all traffic within the VPC.
SubnetCaptures traffic to and from specific subnets.
Network Interface (ENI)Captures traffic specific to an EC2 instance or resource.

🧩 Use Cases​

  • Troubleshoot connectivity failures (e.g., instance can’t reach the internet).
  • Identify rejected connections (due to NACL or Security Group rules).
  • Audit access for services like EC2, RDS, ELB, ElastiCache, and Aurora.

πŸͺ£ Log Destinations​

You can send VPC Flow Logs to any of the following:

DestinationPurpose
Amazon CloudWatch LogsReal-time monitoring and dashboards.
Amazon S3Long-term archival and analytics.
Amazon Kinesis Data FirehoseStream logs for processing or analysis (cross-account supported).

🧾 Log Record Format​

Each flow log record contains key traffic data fields such as:

FieldDescription
versionLog version number
account-idAWS account ID
interface-idENI ID
srcaddr, dstaddrSource and destination IP addresses
srcport, dstportSource and destination ports
protocolProtocol number (e.g., TCP=6, UDP=17)
packets, bytesNumber of packets and bytes transferred
start, endTimestamp of the capture window
actionACCEPT or REJECT
log-statusSUCCESS or FAILURE of logging

2. VPC Peering​

VPC Peering allows two VPCs to connect privately using AWS’s internal network.
It makes the VPCs behave as if they are part of the same network.

PropertyDescription
Connection TypePrivate connection between two VPCs
Traffic FlowUses AWS backbone (no public internet exposure)
CIDR Range RequirementVPCs must have non-overlapping CIDR blocks
Transitive Connectivity❌ Not supported (connections are non-transitive)
Region SupportCan be intra-region or inter-region
OwnershipCan connect VPCs in the same or different AWS accounts

🧩 Example Scenario​

  • VPC A ↔ VPC B β€” Direct peering connection established.
  • If VPC C is introduced:
    • A↔B βœ…
    • A↔C βœ…
    • B↔C ❌ (Requires a separate peering connection)

πŸ“Œ Non-transitive rule: Peering connections must be explicitly created for every pair of VPCs that need to communicate.


🧭 Console Navigation​

To create a Peering Connection:

  1. Go to VPC Console β†’ Peering Connections.
  2. Click Create Peering Connection.
  3. Specify:
    • Requester VPC (local VPC)
    • Accepter VPC (same or different account/region)
  4. Review and create the connection.
  5. The accepter must accept the peering request.

βœ… Summary​

ConceptVPC Flow LogsVPC Peering
PurposeMonitor network trafficPrivately connect VPCs
LevelVPC/Subnet/ENIVPC-to-VPC
DestinationS3, CloudWatch, FirehosePrivate AWS network
CIDR OverlapN/AMust not overlap
TransitivityN/A❌ Non-transitive