AWS Cost Optimization: Complete Guide (2026)
AWS cost optimization is the practice of reducing your AWS bill by right-sizing compute, choosing the right pricing model, tiering storage, minimizing data transfer, and enforcing governance through tagging and budgets — without sacrificing performance.
What You’ll Learn
- Right-sizing EC2 and RDS instances using AWS Compute Optimizer
- Savings Plans vs Reserved Instances — when to use each
- S3 storage tiering with lifecycle policies
- Data transfer cost reduction strategies
- Tagging strategy for cost allocation
- Budget alerts and anomaly detection
- Trusted Advisor cost recommendations
Why It Matters
AWS costs grow exponentially as teams provision resources “just in case.” The average AWS account wastes 30-45% of spend on over-provisioned instances, orphaned volumes, and unnecessary data transfer. A $50k monthly bill can drop to $30k with structured optimization. DodaTech reduced Durga Antivirus Pro’s update infrastructure costs by 40% using Compute Optimizer recommendations and S3 Intelligent-Tiering.
flowchart LR
A[Cost Explorer] --> B[Rightsizing]
B --> C[Savings Plans / RI]
B --> D[Spot Instances]
A --> E[Storage Tiering]
A --> F[Tagging & Budgets]
C --> G[Monthly Savings 30-60%]
style G fill:#f59e0b,color:#fff
1. Cost Visibility with AWS Cost Explorer
AWS Cost Explorer is your starting point. It visualizes spend, forecasts future costs, and identifies top cost drivers.
# Enable Cost Explorer via AWS CLI
aws ce get-cost-and-usage \
--time-period Start=2026-05-01,End=2026-06-01 \
--granularity MONTHLY \
--metrics BlendedCost UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Output shows top services by spendExpected output (abbreviated):
Results by service:
Amazon EC2: $18,230
Amazon S3: $4,120
AWS Lambda: $890
RDS: $3,450
Data Transfer: $2,100Use Cost Categories to group resources by business unit, environment, or project.
2. Right-Sizing EC2 and RDS
The #1 waste driver is over-provisioned compute. AWS Compute Optimizer analyzes utilization and recommends instance type changes.
# Get Compute Optimizer recommendations
aws compute-optimizer get-ec2-instance-recommendations \
--region us-east-1
# Filter for over-provisioned instances
aws compute-optimizer get-ec2-instance-recommendations \
--filters "name=finding,values=Overprovisioned"RDS right-sizing follows the same principle. Use CloudWatch metrics for CPUUtilization, DatabaseConnections, and FreeableMemory:
# Check RDS utilization over 14 days
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name CPUUtilization \
--dimensions Name=DBInstanceIdentifier,Value=prod-db-01 \
--start-time 2026-05-01T00:00:00Z \
--end-time 2026-06-01T00:00:00Z \
--period 3600 \
--statistics AverageRule of thumb: If CPU stays below 20% and memory below 30% for 14 days, downsize one tier. An r5.2xlarge (8 vCPU, 64 GB) running at 12% CPU becomes r5.xlarge (4 vCPU, 32 GB) — saving $252/month.
3. Savings Plans vs Reserved Instances
| Model | Discount | Flexibility | Commitment |
|---|---|---|---|
| Compute Savings Plan | 30-66% | Instance family, region, OS, tenancy | 1 or 3 years |
| EC2 Instance Savings Plan | 30-72% | Instance family within region | 1 or 3 years |
| Standard RI | 30-60% | Specific instance type in AZ | 1 or 3 years |
| Convertible RI | 20-50% | Change instance family/region | 1 or 3 years |
# Purchase a Compute Savings Plan
aws savingsplans create-savings-plan \
--savings-plan-offering-id offering-123456 \
--commitment 100.00 \
--term 1year \
--payment-option PartialUpfrontBuying recommendation: Start with Compute Savings Plans for maximum flexibility. Reserve steady-state baseline at 60-70% of your forecasted spend; run spikes on On-Demand or Spot.
4. S3 Storage Tiers and Lifecycle Policies
S3 offers six storage classes with costs ranging from $0.023/GB (Standard) to $0.00099/GB (Deep Archive).
# Create lifecycle policy to transition data
aws s3api put-bucket-lifecycle-configuration \
--bucket dodatech-logs \
--lifecycle-configuration '{
"Rules": [{
"Id": "log-lifecycle",
"Status": "Enabled",
"Filter": {"Prefix": "access-logs/"},
"Transitions": [
{"Days": 30, "StorageClass": "STANDARD_IA"},
{"Days": 90, "StorageClass": "GLACIER_INSTANT_RETRIEVAL"},
{"Days": 365, "StorageClass": "DEEP_ARCHIVE"}
],
"Expiration": {"Days": 730}
}]
}'
# Use S3 Intelligent-Tiering for unpredictable access patterns
aws s3api put-bucket-lifecycle-configuration \
--bucket dodatech-analytics \
--lifecycle-configuration '{
"Rules": [{
"Id": "intelligent-tiering",
"Status": "Enabled",
"Transitions": [{
"Days": 0,
"StorageClass": "INTELLIGENT_TIERING"
}]
}]
}'Without tiering: 10TB of Standard storage = $230/month. With lifecycle to Glacier after 90 days: $48/month — 79% savings.
5. Data Transfer Costs
Data transfer is the most overlooked cost driver. Egress costs $0.09/GB for internet transfer, $0.02/GB for cross-region, and $0.01/GB for cross-AZ.
# data_transfer_audit.py
services = {
"NAT Gateway": {"hr_rate": 0.045, "gb_rate": 0.045, "hours": 730, "gb": 5000},
"Cross-AZ": {"hr_rate": 0, "gb_rate": 0.01, "hours": 0, "gb": 30000},
"Internet egress": {"hr_rate": 0, "gb_rate": 0.09, "hours": 0, "gb": 2000},
"CloudFront": {"hr_rate": 0, "gb_rate": 0.085, "hours": 0, "gb": 2000},
}
total = 0
for name, s in services.items():
cost = s["hr_rate"] * s["hours"] + s["gb_rate"] * s["gb"]
total += cost
print(f"{name:<20} ${cost:>8.2f}/mo")
print(f"{'TOTAL':<20} ${total:>8.2f}/mo")Expected output:
NAT Gateway $257.85/mo
Cross-AZ $300.00/mo
Internet egress $180.00/mo
CloudFront $85.00/mo
TOTAL $822.85/moMitigation: Use CloudFront (or any CDN) to reduce egress costs. Keep services in the same AZ when possible. Use VPC endpoints for S3 and DynamoDB.
6. Tagging Strategy and Governance
Tags enable cost allocation, chargeback, and automated actions. Enforce a mandatory tag set:
# Enforce required tags with AWS Config
aws configservice put-config-rule \
--config-rule '{
"ConfigRuleName": "required-tags",
"Source": {"Owner": "AWS", "SourceIdentifier": "REQUIRED_TAGS"},
"InputParameters": "{\"tag1Key\":\"Environment\",\"tag1Value\":\"prod,staging,dev\"}"
}'Standard tag taxonomy:
Environment: prod, staging, dev, testProject: web-app, ml-training, data-pipelineTeam: backend, data, ml, devopsCostCenter: cc-1001, cc-1002Owner: alice@example.com
7. Budgets and Alerts
Set budgets with alerts at 50%, 80%, 90%, and 100% to prevent bill shock.
# Create a budget alert
aws budgets create-budget \
--account-id 123456789012 \
--budget '{
"BudgetName": "monthly-compute",
"BudgetLimit": {"Amount": 15000, "Unit": "USD"},
"TimeUnit": "MONTHLY",
"BudgetType": "COST",
"CostFilters": {"Service": ["AmazonEC2"]}
}' \
--notifications-with-subscribers '[
{"Notification":{"NotificationType":"ACTUAL","ComparisonOperator":"GREATER_THAN","Threshold":80,"ThresholdType":"PERCENTAGE"},
"Subscribers":[{"SubscriptionType":"EMAIL","Address":"finops@example.com"}]}
]'8. Trusted Advisor Recommendations
AWS Trusted Advisor checks 200+ best practices across cost, performance, security, and fault tolerance.
# List cost optimization checks
aws support describe-trusted-advisor-checks \
--language en \
--query "checks[?category=='cost_optimizing']"
# Refresh and get check results
aws support refresh-trusted-advisor-check \
--check-id check-id-123
aws support describe-trusted-advisor-check-result \
--check-id check-id-123Common Mistakes
No budget alerts: A single misconfigured resource can run $100k overnight. Set alerts at 50/80/90/100% of every budget.
Right-sizing only once: Workloads change. Review Compute Optimizer recommendations monthly and rightsize continuously.
Orphaned EBS volumes: Deleting an EC2 instance does not delete attached EBS volumes. Use
aws ec2 describe-volumes --filters "Name=status,Values=available"to find and clean them.Ignoring data transfer costs: Cross-region traffic, NAT Gateway, and egress are expensive. Design workloads to minimize inter-region and internet data movement.
Skipping Storage Tiering: Keeping all data in S3 Standard is 20x more expensive than transitioning cold data to Glacier or Deep Archive.
Practice Questions
What is the difference between a Compute Savings Plan and an EC2 Instance Savings Plan? Answer: Compute Savings Plan applies to any EC2 instance, Lambda, and Fargate across regions. EC2 Instance Savings Plan applies to a specific instance family within a region but offers higher discounts.
When should you use S3 Intelligent-Tiering vs lifecycle policies? Answer: Use Intelligent-Tiering when access patterns are unknown or unpredictable. Use lifecycle policies when patterns are known (e.g., logs transition to Glacier after 90 days).
How do you detect orphaned EBS volumes? Answer:
aws ec2 describe-volumes --filters "Name=status,Values=available"lists unattached volumes. Automate deletion with a Lambda function triggered by CloudWatch Events.What is the most effective single action to reduce AWS costs? Answer: Enable AWS Compute Optimizer and implement its rightsizing recommendations. This alone typically saves 20-35% of compute spend.
Challenge
Audit a $75k/month AWS account: pull Cost Explorer data for the last 3 months, identify the top 3 services by spend, run Compute Optimizer for all EC2 and RDS instances, create lifecycle policies for all S3 buckets without them, implement a required tagging policy with AWS Config, and set up budget alerts for every service exceeding $1k/month.
FAQ
What’s Next
| Topic | Description |
|---|---|
| Deep dive into commitment-based discounts | |
| 80-90% discount on compute |
Related topics: Cloud Cost Optimization, Multi-Cloud, Cloud Computing
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro