Terminate unnecessary NAT Gateway costs by detecting services that should use VPC endpoints.
termiNATor is a CLI tool that analyzes your AWS NAT Gateway traffic to identify cost optimization opportunities. It detects when your applications are routing traffic to AWS services (like S3 and DynamoDB) through NAT Gateways instead of using free VPC Gateway Endpoints, helping you eliminate unnecessary data processing charges.
NAT Gateways charge $0.045 per GB for data processing. If your applications access S3 or DynamoDB through a NAT Gateway, you’re paying for traffic that could be completely free using Gateway VPC Endpoints.
Example Savings:
# Install
git clone https://github.com/eranchetz/termiNAT.git
cd terminator
go build -o terminat
# Configure AWS credentials
export AWS_PROFILE=your-profile
export AWS_REGION=us-east-1
# Run quick scan (instant, no resources created)
./terminat scan quick --region us-east-1
# Run deep dive scan (analyzes actual traffic)
./terminat scan deep --region us-east-1 --duration 5
# Narrow the scan to one VPC
./terminat scan deep --region us-east-1 --vpc-id vpc-xxx --duration 5
# Scan multiple VPCs or NAT Gateways in the same region
./terminat scan deep --region us-east-1 --vpc-ids vpc-a,vpc-b --nat-gateway-ids nat-a,nat-b --duration 5
# Run demo scan with fake data (stream output by default)
./terminat scan demo
# Optional: run interactive full-screen TUI instead of serial stream output
./terminat scan deep --region us-east-1 --duration 5 --ui tui
./terminat scan demo --ui tui
📖 Complete Usage Guide - Detailed instructions for production use
🧪 E2E Testing Guide - Run automated tests with sample infrastructure
go install github.com/doitintl/terminator@latest
Or build from source:
git clone https://github.com/eranchetz/termiNAT.git
cd terminator
go build -o terminat
Configure AWS credentials using one of these methods:
# AWS CLI configuration
aws configure
# Environment variables
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_REGION="us-east-1"
# AWS Profile
export AWS_PROFILE="your-profile"
For Quick Scan, you need read-only permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeNatGateways",
"ec2:DescribeVpcEndpoints",
"ec2:DescribeRouteTables",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs"
],
"Resource": "*"
}
]
}
For Deep Dive Scan, additional permissions are required:
# Run the setup script to create the IAM role
./scripts/setup-flowlogs-role.sh
This creates a role with permissions for:
Instantly analyze your VPC configuration:
terminat scan quick --region us-east-1
This will:
Analyze actual traffic patterns:
terminat scan deep --region us-east-1 --duration 5
By default, scans run in serial stream mode (--ui stream) so output is append-only and CI/log friendly.
Use --ui tui for the interactive Bubble Tea interface.
This will:
Total time: Flow Logs activation time + collection duration
Example output:
NAT Gateway Topology:
nat-1234567890abcdef0 (zonal, vpc-abcd1234)
VPC Endpoint Configuration:
Gateway Endpoints:
✗ S3: NOT CONFIGURED
✗ DynamoDB: NOT CONFIGURED
ECR Interface Endpoints (Paid):
⚠ ECR API (ecr.api): MISSING
⚠ ECR DKR (ecr.dkr): MISSING
Traffic Analysis:
Total: 1,234 records, 45.67 GB
S3: 890 records, 32.10 GB (70.3%)
DynamoDB: 234 records, 8.45 GB (18.5%)
ECR: 100 records, 2.45 GB (5.4%)
Other: 110 records, 5.12 GB (11.2%)
Cost Savings Estimate:
Current Monthly NAT Gateway Cost: $61.45
Potential Savings with VPC Endpoints: $54.74/month ($656.88/year)
⚠️ IMPORTANT: This is an ESTIMATE based on the traffic sample collected.
# Quick scan
terminat scan quick --region <region>
# Deep dive scan
terminat scan deep --region <region> --duration <minutes>
# Demo scan (fake data, no AWS credentials needed)
terminat scan demo
# Export markdown report to persistent reports/ folder
terminat scan deep --region us-east-1 --duration 5 --export markdown --output reports/terminat-report-$(date +%Y%m%d-%H%M%S).md
# Skip doctor preflight (enabled by default)
terminat scan quick --region <region> --doctor=false
# Optional TUI mode
terminat scan quick --region <region> --ui tui
terminat scan deep --region <region> --duration <minutes> --ui tui
terminat scan demo --ui tui
# Scan specific NAT Gateway
terminat scan deep --region us-east-1 --nat-gateway-ids nat-1234567890abcdef0
--ui stream) for scan quick, scan deep, and scan demo.--ui tui only when you want the interactive full-screen Bubble Tea experience.scan quick and scan deep run doctor preflight checks by default.--doctor=false when needed.Run the smoke test to verify stream-mode CLI wiring without creating AWS resources:
./test/scripts/smoke-ui-stream.sh
After a Deep Dive scan, Flow Logs data is retained for your review. Clean it up when done:
# List log groups
aws logs describe-log-groups --log-group-name-prefix "/aws/vpc/flowlogs/terminat"
# Delete log group
terminat cleanup --region us-east-1 --log-group "/aws/vpc/flowlogs/terminat-1234567890"
NAT Gateway Pricing:
VPC Gateway Endpoints:
ECR Interface Endpoints (paid):
internal/analysis/endpoints.go table and is treated as an estimate; verify current AWS PrivateLink pricing for your region before provisioning.Important Notes:
terminator/
├── cmd/ # CLI commands (scan, cleanup)
├── internal/
│ ├── core/ # Core business logic (scanner)
│ ├── aws/ # AWS service clients (EC2, CloudWatch)
│ ├── analysis/ # Traffic analysis and cost calculation
│ └── report/ # Report generation (future)
├── pkg/ # Public APIs and types
├── ui/ # Terminal UI components
└── scripts/ # Setup and utility scripts
ec2:DescribeNatGateways./scripts/setup-flowlogs-role.sh to create the required IAM roleContributions are welcome! Please feel free to submit a Pull Request.
Apache License 2.0
For issues and questions:
Made with ❤️ by DoiT International