← Back to AWS Mastery
Advanced13 min read

Cost Optimization

Optimize AWS spending — Reserved Instances, Savings Plans, Cost Explorer analysis, and architectural patterns that reduce cloud costs.

Understanding AWS Pricing

AWS charges for compute (per hour/second), storage (per GB/month), data transfer (per GB), and requests. Pricing varies by region. Data transfer OUT to internet is charged; transfer IN is free. Cross-AZ transfer incurs charges.

Use the AWS Pricing Calculator to estimate costs before deployment. Review the AWS Cost Management dashboard monthly.

  • On-demand: pay by the hour/second, no commitment
  • Reserved/Savings Plans: 1-3 year commitment, up to 72% savings
  • Spot Instances: up to 90% discount, can be interrupted
# Estimate monthly cost
# EC2 t3.large: ~$60/month (on-demand)
# RDS db.t3.medium: ~$50/month
# S3 100GB Standard: ~$2.30/month
# Data transfer 1TB out: ~$90/month
# Total estimate with Pricing Calculator

Reserved Instances and Savings Plans

Reserved Instances (RI) commit to specific instance type and region for 1 or 3 years. Savings Plans commit to dollar amount per hour for compute usage — more flexible across instance types and regions.

Analyze RI recommendations in Cost Explorer. Purchase RIs for steady-state baseline capacity. Use Savings Plans for variable but predictable compute spend.

# Check RI recommendations
aws ce get-reservation-purchase-recommendation \
  --service "Amazon Elastic Compute Cloud - Compute"

# Savings Plans types:
# Compute Savings Plans — any EC2, Fargate, Lambda (most flexible)
# EC2 Instance Savings Plans — specific instance family

Cost Explorer and Analysis

Cost Explorer visualizes spending by service, region, tag, and time period. Identify top cost drivers and trends. Create custom reports for weekly reviews. Use Cost Anomaly Detection for automatic alerts on unusual spending.

Tag all resources consistently: Environment, Project, Team, CostCenter. Activate cost allocation tags in Billing preferences.

# Find top spending services (CLI)
aws ce get-cost-and-usage \
  --time-period Start=2024-01-01,End=2024-01-31 \
  --granularity MONTHLY \
  --metrics BlendedCost \
  --group-by Type=DIMENSION,Key=SERVICE

Architectural Cost Optimization

Right-size instances — many workloads run on oversized instances. Use Compute Optimizer recommendations. Move infrequently accessed S3 data to cheaper storage classes. Use Spot Instances for batch processing and fault-tolerant workloads.

Serverless (Lambda, DynamoDB on-demand) eliminates idle costs for variable traffic. Auto Scaling ensures you pay for what you use during traffic spikes without over-provisioning.

# Cost optimization checklist
# ✓ Right-size EC2 with Compute Optimizer
# ✓ S3 lifecycle policies for storage class transitions
# ✓ Delete unused EBS volumes and snapshots
# ✓ Use Graviton (ARM) instances for 20% savings
# ✓ Enable S3 Intelligent-Tiering
# ✓ Review NAT Gateway costs (consider VPC endpoints)
# ✓ Delete unused Elastic IPs ($3.60/month each)

FinOps Practices

Establish a FinOps culture: engineering teams share cost responsibility. Set budgets per team/project. Review costs in sprint retrospectives. Implement automatic shutdown of dev/staging environments outside business hours.

Use AWS Budgets with SNS alerts at 80% and 100% thresholds. Create a monthly cost review meeting with engineering and finance stakeholders.

  • FinOps Foundation provides framework for cloud financial management
  • Unit economics: cost per customer, cost per transaction
  • Showback/chargeback drives accountability without actual billing
# Auto-stop dev instances with Lambda + EventBridge
# Schedule: stop at 7 PM, start at 7 AM weekdays
# EventBridge rule → Lambda → ec2.stop_instances
# Savings: ~65% on dev environment compute costs

Get In Touch


Ready to discuss your next project? Drop me a message.