Overview
VPC Flow Logs capture information about IP traffic to and from network interfaces in your VPC. They can be enabled at:
- VPC level
- Subnet level
- Elastic Network Interface (ENI) level
Types:
- VPC-level Flow Logs
- Subnet-level Flow Logs
- ENI-level Flow Logs
Use Cases
- Monitor and troubleshoot connectivity.
- Analyze traffic for security, compliance, and performance.
- Detect anomalies such as port scans or suspicious IPs.
Destinations
Flow log data can be sent to:
- Amazon CloudWatch Logs
- Amazon S3
- Amazon Kinesis Data Firehose
Supported AWS Services
Can capture data from AWS-managed interfaces, including:
- Elastic Load Balancer (ELB)
- RDS
- ElastiCache
- Redshift
- WorkSpaces
- NAT Gateway
- Transit Gateway
Architecture Context
- Public Subnet: Public EC2 instances, IGW, SG/NACL, public route table.
- Private Subnet: Private EC2 instances, NAT Gateway for outbound internet, private route table.
- Flow logs collect data from network interfaces in these subnets, as well as from VPC Peering links and VPC Endpoints.
Flow Log Record – Key Fields
- srcaddr / dstaddr – Source/Destination IP
- srcport / dstport – Source/Destination Port
- protocol – Protocol used (TCP/UDP)
- action – ACCEPT or REJECT
- log-status – Log capture status
- packets, bytes – Traffic volume
- start / end – Flow timestamps
Querying tools:
- Athena (for logs in S3)
- CloudWatch Logs Insights (for logs in CloudWatch)
Troubleshooting SG & NACL Issues
- SGs are stateful: allow return traffic automatically.
- NACLs are stateless: must allow both inbound and outbound explicitly.
REJECT
in inbound direction → likely NACL inbound or SG inbound block.
ACCEPT
inbound butREJECT
outbound → likely NACL outbound block.
Example Architectures
1. CloudWatch Logs Integration
- Flow Logs → CloudWatch Logs → Contributor Insights & Metric Filters
- Detect top talkers, traffic trends, or unauthorized protocol use.
- SNS alerts for events like SSH/RDP attempts.
2. S3 + Athena
- Flow Logs → S3 → Athena queries
- Visualize with QuickSight for audit/compliance dashboards.