A CDK application that implements intelligent traffic routing using Lambda@Edge functions, DynamoDB global tables, and CloudFront distribution with comprehensive security and monitoring.
- DynamoDB Global Tables: User routing data replicated across regions
- Lambda@Edge Functions: Traffic routing and region setting at edge locations
- CloudFront Distribution: Global content delivery with WAF protection
- AWS Config: Continuous compliance monitoring
- S3 Buckets: Access logs and configuration storage
- CDK Nag: Security and compliance validation
- Python 3.12+
- AWS CDK CLI
- AWS CLI configured with appropriate permissions
- Lambda function code in
lambda_code/directories
- Install dependencies:
pip install -r requirements.txt- Bootstrap CDK (if not done previously):
cdk bootstrap- Set endpoint context:
cdk deploy --context endpoint=your-origin-domain.com- Deploy with custom suffix (for testing):
cdk deploy --context endpoint=example.com --context suffix=_test- Synthesize without deploying:
cdk synth --context endpoint=example.com├── app.py # CDK app entry point
├── lambdaEdgeCDK.py # Main stack definition
├── lambda_code/
│ ├── routeTraffic/ # Origin request Lambda@Edge
│ └── setRegion/ # Origin response Lambda@Edge
├── requirements.txt # Python dependencies
└── generate_nag_report.py # Report generation
user_ids: User routing configurationapp_config: Application settings- Global replication to us-west-2 and eu-west-1
- Point-in-time recovery enabled
routeTraffic: Origin request handlersetRegion: Origin response handler- Python 3.12 runtime
- Least privilege IAM roles
- HTTPS-only origin protocol
- Custom cache and origin request policies
- WAF protection with AWS managed rules
- Access logging to S3
- TLS 1.2 minimum protocol
- AWS WAF with common rule set
- S3 bucket encryption
- IAM least privilege access
- CloudTrail data plane events
- AWS Config compliance monitoring
endpoint: Origin domain (required)suffix: Resource name suffix (optional, for testing)
cdk destroy --context endpoint=example.com
make clean # Remove generated files- Create function directories under
lambda_code/ - Add
index.pywithhandlerfunction - Update stack to reference new functions
- Update suppressions in
app.py - Run
make nag-testto validate - Review generated reports
- CloudWatch: Lambda execution metrics
- WAF: Request filtering and blocking
- S3 Access Logs: Request analysis
- AWS Config: Resource compliance
- CDK Nag Reports: Security validation
- Ensure Lambda code exists in
lambda_code/directories - Verify AWS credentials and permissions
- Check CDK bootstrap status
- Review CloudFormation events for deployment issues