AWS Cost Management
AWS Cost Management
Section titled โAWS Cost ManagementโUnderstanding AWS pricing and managing cloud spend is a critical skill. AWS provides a set of tools to visualize, analyze, and control costs.
In Azure terms: See Azure Cost Management + Billing equivalents below.
AWS Pricing Models
Section titled โAWS Pricing Modelsโ| Model | Description | Best For |
|---|---|---|
| On-Demand | Pay by the second, no commitment | Dev/test, unpredictable workloads |
| Reserved Instances (RI) | 1 or 3-year commitment on specific instance type, up to 72% off | Steady-state production |
| Savings Plans | Flexible spending commitment ($/hour), up to 66% off | Mix of instance types and Fargate |
| Spot Instances | Spare EC2 capacity, up to 90% off, can be interrupted | Batch jobs, ML training, fault-tolerant apps |
| Dedicated Hosts | Physical server reserved for you | License compliance (Windows, SQL Server) |
| Free Tier | 12-month + always-free services | Learning and experimentation |
Savings Plans vs Reserved Instances
Section titled โSavings Plans vs Reserved Instancesโ| Feature | Savings Plans | Reserved Instances |
|---|---|---|
| Flexibility | Apply to any instance type/region (Compute SP) | Specific instance type and region |
| Discount | Up to 66% | Up to 72% |
| Term | 1 or 3 years | 1 or 3 years |
| Payment | Upfront, partial, or no upfront | Same |
| Scope | EC2 + Lambda + Fargate | EC2 only (usually) |
Recommendation: Savings Plans are generally more flexible and preferred for most teams.
Cost Management Tools
Section titled โCost Management ToolsโAWS Cost Explorer
Section titled โAWS Cost ExplorerโVisualize and analyze historical spending and usage:
- View costs by service, region, account, tag, or resource
- Identify trends and anomalies
- Forecast future spend
- View Reserved Instance and Savings Plans utilization
AWS Budgets
Section titled โAWS BudgetsโSet cost and usage thresholds with alerts:
| Budget Type | Triggers On |
|---|---|
| Cost Budget | Actual or forecasted cost exceeds $X |
| Usage Budget | Usage (hours, GB, requests) exceeds threshold |
| Reservation Budget | RI utilization drops below X% |
| Savings Plans Budget | SP utilization drops below X% |
# Create a monthly cost budget with email alertaws budgets create-budget \ --account-id 123456789012 \ --budget '{ "BudgetName": "monthly-limit", "BudgetLimit": {"Amount": "500", "Unit": "USD"}, "TimeUnit": "MONTHLY", "BudgetType": "COST" }' \ --notifications-with-subscribers '[{ "Notification": { "NotificationType": "ACTUAL", "ComparisonOperator": "GREATER_THAN", "Threshold": 80 }, "Subscribers": [{"SubscriptionType": "EMAIL", "Address": "team@example.com"}] }]'AWS Cost Anomaly Detection
Section titled โAWS Cost Anomaly DetectionโML-powered detection of unexpected cost spikes:
- Set thresholds (e.g., alert if spend is $X above expected)
- Get notified via SNS/email
- Drill into root causes
AWS Compute Optimizer
Section titled โAWS Compute OptimizerโAnalyzes EC2, Lambda, EBS, and ECS utilization to recommend right-sizing:
- Identifies over-provisioned (too large) and under-provisioned (too small) resources
- Provides specific instance type recommendations with estimated savings
Tagging Strategy for Cost Allocation
Section titled โTagging Strategy for Cost AllocationโTags are essential for attributing costs to teams, projects, or environments:
| Tag Key | Example Values |
|---|---|
Environment | prod, staging, dev, test |
Team | backend, frontend, data, platform |
Project | checkout, payments, auth |
CostCenter | 1234, marketing, engineering |
Owner | alice, bob |
Activate tags for billing: In the AWS Billing console โ Cost Allocation Tags โ activate your tag keys. It takes 24 hours for them to appear in Cost Explorer.
Cost Optimization Quick Wins
Section titled โCost Optimization Quick Winsโ| Action | Typical Savings |
|---|---|
| Delete unattached EBS volumes | 100% of that volume cost |
| Release unused Elastic IPs | $0.005/hour (~$3.60/month each) |
| Delete unused Load Balancers | $16โ$25/month each |
| Switch EC2 gp2 to gp3 EBS | 20% cost reduction |
| Buy Savings Plans (1-year) | 30โ40% off compute |
| Move to Graviton (ARM) instances | 20% cheaper than x86 equivalents |
| Use S3 Intelligent-Tiering | Automatic tier-down for infrequent access |
| Enable S3 lifecycle policies | Move data to Glacier after 90 days |
AWS vs Azure Cost Tools
Section titled โAWS vs Azure Cost Toolsโ| Tool | AWS | Azure |
|---|---|---|
| Cost visualization | Cost Explorer | Azure Cost Management |
| Budgets & alerts | AWS Budgets | Azure Budgets |
| Pricing calculator | AWS Pricing Calculator | Azure Pricing Calculator |
| Anomaly detection | Cost Anomaly Detection | Azure Cost Alerts (smart alerts) |
| Right-sizing | Compute Optimizer | Azure Advisor |
| Reserved pricing | Reserved Instances | Reserved VM Instances |
| Flexible reserved | Savings Plans | Azure Savings Plan for Compute |
| Spot pricing | EC2 Spot Instances | Azure Spot VMs |