Overview
The GovTech platform uses AWS Cost Explorer, Cost Anomaly Detection, and infrastructure best practices to maintain cost efficiency while meeting performance and compliance requirements.Cost Monitoring
AWS Cost Anomaly Detection
Automated anomaly detection alerts on unusual spending patterns:terraform/modules/security/aws.tf
Cost Anomaly Detection uses machine learning to establish baseline spending patterns and alerts when actual costs deviate significantly.
What Triggers Alerts
Unusual Service Costs
Unusual Service Costs
Examples:
- EKS costs increase from 600/month
- S3 data transfer jumps from 100GB to 2TB
- RDS costs spike due to increased IOPS
New Service Usage
New Service Usage
Detection of previously unused services:
- Someone launches EC2 instances (not part of architecture)
- NAT Gateway data transfer increases significantly
- New AWS service activated
Regional Anomalies
Regional Anomalies
Unexpected costs in non-primary regions:
- Resources created in wrong region
- Cross-region data transfer
Cost Breakdown by Environment
Development Environment
| Service | Resource | Monthly Cost | Annual |
|---|---|---|---|
| EKS | Control plane | $73 | $876 |
| EC2 | 2x t3.medium nodes | $60 | $720 |
| RDS | db.t3.micro | $15 | $180 |
| ALB | Application Load Balancer | $18 | $216 |
| NAT Gateway | 1 NAT GW | $32 | $384 |
| S3 | Storage + requests | $5 | $60 |
| Total | ~$180/month | ~$2,160/year |
Production Environment
| Service | Resource | Monthly Cost | Annual |
|---|---|---|---|
| EKS | Control plane | $73 | $876 |
| EC2 | 3-10x t3.medium nodes (avg 5) | $150 | $1,800 |
| RDS | db.t3.small Multi-AZ | $75 | $900 |
| ALB | Application Load Balancer | $25 | $300 |
| NAT Gateway | 3 NAT GW (Multi-AZ) | $96 | $1,152 |
| S3 | Storage + backups | $20 | $240 |
| CloudWatch | Logs + metrics | $15 | $180 |
| Secrets Manager | Secrets storage | $5 | $60 |
| Total | ~$335/month | ~$4,020/year |
Actual costs vary based on:
- Traffic volume (ALB processing, NAT Gateway data transfer)
- Auto-scaling (EKS node count)
- Storage growth (RDS, S3)
- Data transfer out to internet
Cost Optimization Strategies
1. Right-Sizing EC2 Instances
2. Optimize RDS Instances
Use Multi-AZ Only in Production
Multi-AZ doubles RDS costs. Only enable for production:Savings: ~50% for dev/staging
Enable Storage Autoscaling
Start small, grow as needed:Savings: Pay only for used storage
3. S3 Cost Optimization
Lifecycle Policies
Lifecycle Policies
Automatically transition objects to cheaper storage classes:Savings: 50-80% on older backups
terraform/modules/storage/aws.tf
Intelligent Tiering
Intelligent Tiering
For unpredictable access patterns:
Delete Incomplete Multipart Uploads
Delete Incomplete Multipart Uploads
Clean up abandoned uploads:Savings: Small but eliminates waste
4. NAT Gateway Optimization
Options:- Current (Multi-AZ)
- Single NAT Gateway
- VPC Endpoints
Production: 3 NAT Gateways (one per AZ)
- High availability
- No cross-AZ data transfer costs
- Cost: $96/month + data transfer
5. EKS Cost Optimization
Enable Cluster Autoscaler
Scale nodes based on actual pod resource requests:Savings: Only run nodes when needed (especially off-hours)
6. Reserved Instances and Savings Plans
For stable production workloads, commit to 1 or 3 years:| Commitment | Discount | Best For |
|---|---|---|
| 1-year No Upfront | 20-40% | Predictable baseline |
| 1-year All Upfront | 30-50% | Known requirements |
| 3-year All Upfront | 40-60% | Long-term stable workloads |
- Reserve capacity for minimum baseline (e.g., 2 nodes always running)
- Use on-demand/spot for auto-scaling
Cost Monitoring Tools
AWS Cost Explorer
Access: AWS Console > Cost Management > Cost Explorer Key Reports:- Monthly costs by service: Identify largest cost drivers
- Cost by tag: Track costs per environment (
Environment: prod/dev) - Daily spend trend: Detect sudden increases
- Reserved Instance utilization: Ensure RIs are being used
Cost Allocation Tags
Ensure all resources are tagged:Common tags
Budgets and Alerts
Set up AWS Budgets for proactive monitoring:Quick Wins Checklist
- Enable S3 lifecycle policies for backups (50% savings)
- Use single NAT Gateway in dev environment ($64/month savings)
- Disable Multi-AZ RDS in dev/staging (50% RDS savings)
- Delete unattached EBS volumes and old snapshots
- Enable Cost Anomaly Detection alerts
- Set up AWS Budgets for each environment
- Review and delete unused Elastic IPs ($3.60/month each)
- Enable EKS cluster autoscaler
- Use Spot instances for dev/staging workloads
- Create VPC endpoints for S3 and ECR
Cost Optimization Review Schedule
| Activity | Frequency | Owner |
|---|---|---|
| Review Cost Explorer | Weekly | DevOps |
| Analyze anomaly alerts | As triggered | DevOps |
| Right-sizing analysis | Monthly | Infrastructure |
| Reserved Instance review | Quarterly | Finance + DevOps |
| Budget vs actual review | Monthly | Project Lead |
| Tag compliance audit | Monthly | DevOps |
Useful Cost Queries
Related Resources
Monitoring
Resource utilization dashboards and metrics
Architecture
Infrastructure architecture and design decisions