Here’s our complete implementation architecture that addresses VPC Flow Logs aggregation, S3 object lock for immutability, and Athena for audit queries:
VPC Flow Logs Aggregation Setup:
Enabled VPC Flow Logs on all 12 VPCs in our cardholder data environment with custom format to capture additional fields required by PCI auditors. Flow logs publish directly to centralized S3 bucket in us-east-1 with prefix structure: vpc-flow-logs/year=YYYY/month=MM/day=DD/vpc-id=vpc-xxxxx/. This partitioning strategy is crucial for efficient Athena queries.
Configuration applied to each VPC:
- Traffic Type: ALL (accepted and rejected traffic)
- Destination: S3 bucket with server-side encryption (SSE-S3)
- Log Format: Custom format including srcaddr, dstaddr, srcport, dstport, protocol, packets, bytes, start, end, action, log-status
- Max Aggregation Interval: 1 minute for near real-time visibility
S3 Object Lock for Immutability:
The centralized S3 bucket configuration ensures immutability for PCI compliance:
- Object Lock enabled in compliance mode (cannot be disabled, even by root account)
- Default retention period: 7 years to exceed PCI requirement
- Bucket versioning enabled (required for Object Lock)
- MFA Delete enabled for additional protection
- Bucket policy denies s3:DeleteObject and s3:DeleteObjectVersion for all principals
- Cross-region replication to backup bucket (also with Object Lock) in us-west-2
S3 Lifecycle policy transitions:
- 0-90 days: S3 Standard
- 91-365 days: S3 Standard-IA
- 366 days+: S3 Glacier Deep Archive
This tiered approach reduced storage costs by 65% while maintaining immutability and compliance.
Athena for Audit Queries:
Implemented automated Glue Data Catalog setup:
- Glue Crawler runs daily to discover new partitions (year/month/day/vpc-id)
- Created Glue ETL job that converts raw VPC Flow Logs to Parquet format with Snappy compression
- Parquet conversion happens nightly, reduces data scanned by Athena by 85%
- Separate Athena workgroup for compliance team with query result encryption
Common audit queries saved as named queries:
- All rejected traffic to CDE subnets (identifies potential attacks)
- Traffic from specific IP to payment application servers (incident investigation)
- Unusual port access patterns (anomaly detection)
- Data transfer volumes by source/destination (data exfiltration detection)
Query performance: Average audit query completes in 8-12 seconds scanning 2-5GB of data.
PCI Audit Evidence Collection:
During quarterly PCI assessments, QSA auditors use Athena to:
- Verify all network traffic to/from CDE is logged (Requirement 10.2.7)
- Investigate security incidents by querying specific timeframes
- Validate network segmentation by confirming no unauthorized traffic flows
- Generate reports showing rejected connection attempts
Created Athena views that pre-filter for CDE-relevant traffic, making it easy for auditors to run queries without understanding complex VPC Flow Log schema.
Automation and Monitoring:
- CloudWatch Events trigger Lambda function when new VPC is created, automatically enabling Flow Logs
- SNS notification if Flow Log delivery to S3 fails
- CloudWatch dashboard showing log delivery metrics and S3 bucket size
- Monthly cost allocation report for flow logs infrastructure
Cost Analysis:
Monthly costs for 12 VPCs with ~800GB flow logs:
- VPC Flow Logs publishing: $360 (12 VPCs × $30/VPC)
- S3 storage (tiered): $285
- Cross-region replication: $120
- Glue Crawler and ETL: $85
- Athena queries: $40 (during audit periods)
Total: ~$890/month
Lessons Learned:
- Enable Flow Logs early - historical data cannot be retroactively generated
- Parquet conversion is essential for reasonable Athena query costs and performance
- Object Lock compliance mode requires careful planning - retention cannot be shortened
- Custom log format provides better audit evidence than default format
- Partition projection in Athena eliminates need for Glue Crawler in some scenarios
PCI Audit Outcome:
QSA validated our implementation fully satisfies PCI DSS Requirements 10.2.7 (audit trail for all access to network resources and cardholder data) and 10.5 (secure audit trails). The immutability provided by S3 Object Lock and queryability through Athena significantly streamlined the audit process. What previously took 2 days of manual log analysis now takes 2 hours of running pre-built Athena queries.
This architecture successfully addresses all three focus areas: centralized VPC Flow Logs aggregation provides comprehensive network visibility, S3 Object Lock ensures immutability for compliance evidence, and Athena enables efficient audit queries for PCI assessments.