AWS Certified Cloud Practitioner

Post 16 of 25

64%

Complete

Cloud Architecture7 min read

AWS Cloud Practitioner #16: Cost Management y Optimization Tools

Aprende Cost Explorer, Budgets, Cost Anomaly Detection, y Compute Optimizer para gestionar y reducir costos de AWS.

🎯 Lo que Aprenderás Hoy

  • Usar AWS Cost Explorer para análisis
  • Configurar AWS Budgets y alerts
  • Detectar anomalías de costos
  • Optimizar con Compute Optimizer
  • Implementar cost allocation tags

AWS Cost Explorer

¿Qué es? Herramienta visual para analizar y gestionar costos.

Features Principales

plaintext
1. Cost and Usage Visualization
   - Graphs interactivos
   - Filter por service, region, tag
   - Time range: Últimos 12 meses
   - Forecast: Próximos 12 meses
 
2. Grouping y Filtering
   Group by:
   - Service (EC2, S3, RDS)
   - Region (us-east-1, eu-west-1)
   - Instance type (t3.micro, m5.large)
   - Tag (Environment, Project)
   - Account (multi-account)
 
3. Forecasting
   - Machine learning predictions
   - Based on historical usage
   - 80% confidence interval
 
4. Reports
   - Reserved Instance utilization
   - Savings Plans utilization
   - Reserved Instance recommendations

Ejemplo de Uso

plaintext
Pregunta: "¿Por qué aumentaron costos este mes?"
 
Cost Explorer steps:
1. Time range: Last 3 months
2. Group by: Service
3. Result:
   - EC2: $500 (stable)
   - S3: $1,200 (up from $300) ← Anomaly
   - RDS: $400 (stable)
 
4. Drill down S3:
   Group by: Region
   - us-east-1: $300 (normal)
   - us-west-2: $900 (NEW) ← Found it
 
Root cause: New project deployed en us-west-2

AWS Budgets

¿Qué es? Set cost/usage limits con automated alerts.

Budget Types

1. Cost Budget

plaintext
Example:
Budget: $500/month
Threshold alerts:
- 50% ($250): Email notification
- 80% ($400): Email + SNS
- 100% ($500): Email + SNS + Custom action
 
Custom action:
→ Lambda function stops dev instances

2. Usage Budget

plaintext
Example:
Service: EC2
Metric: Instance hours
Limit: 750 hours/month (Free Tier)
 
Alert at:
- 80% (600 hours): "Close to Free Tier limit"
- 100% (750 hours): "Free Tier exceeded"

3. Reservation Budget

plaintext
Track Reserved Instance utilization:
 
Target: 80% utilization
Current: 65%
 
Alert: "Reserved Instances underutilized"
→ Investigation needed

4. Savings Plans Budget

plaintext
Track Savings Plans coverage:
 
Target: 70% coverage
Current: 50%
 
Alert: "Consider purchasing more Savings Plans"

Crear Budget

bash
aws budgets create-budget \
  --account-id 123456789012 \
  --budget '{
    "BudgetName": "Monthly-Cost-Budget",
    "BudgetLimit": {
      "Amount": "500",
      "Unit": "USD"
    },
    "TimeUnit": "MONTHLY",
    "BudgetType": "COST"
  }' \
  --notifications-with-subscribers '[{
    "Notification": {
      "NotificationType": "ACTUAL",
      "ComparisonOperator": "GREATER_THAN",
      "Threshold": 80
    },
    "Subscribers": [{
      "SubscriptionType": "EMAIL",
      "Address": "finance@empresa.com"
    }]
  }]'

AWS Cost Anomaly Detection

¿Qué es? Machine learning detecta spending anomalies automáticamente.

plaintext
Cómo funciona:
1. Aprende patrones normales de gasto
2. Detecta deviations significativas
3. Envía alerts automáticas
 
Example anomaly:
Normal: EC2 = $300/semana
Detected: EC2 = $1,200 esta semana (+300%)
 
Alert email:
Subject: "Cost Anomaly Detected: EC2"
Impact: $900 additional
Possible cause: 10 new t3.xlarge instances
Action: Investigate immediately

Benefits:

plaintext
✅ Automatic detection (no manual monitoring)
✅ Reduces surprise bills
✅ Early warning system
✅ Identifica waste rápidamente
 
Setup:
1. Console → Cost Anomaly Detection
2. Create monitor (All services o specific)
3. Set alert threshold ($100+)
4. Add subscribers (email/SNS)

AWS Compute Optimizer

¿Qué es? Analiza resources y recomienda optimal configurations.

Resources Analyzed

plaintext
1. EC2 Instances
   Recommendations:
   - Right-size (larger/smaller)
   - Change instance family
   - Estimated savings
 
2. EBS Volumes
   - Change volume type (gp2 → gp3)
   - Resize volume
   - Delete unused
 
3. Lambda Functions
   - Optimize memory allocation
   - Reduce over-provisioning
 
4. Auto Scaling Groups
   - Adjust min/max/desired
   - Instance type recommendations

Ejemplo Recommendation

plaintext
Current Configuration:
Instance: t3.large (2 vCPU, 8 GB)
Cost: $60/month
CPU utilization: 15%
Memory utilization: 30%
 
Recommendation:
Instance: t3.small (2 vCPU, 2 GB)
Cost: $15/month
Projected utilization: 60% CPU, 90% memory
Savings: $45/month (75% reduction)
 
Confidence: High (based on 14 days metrics)

Habilitar:

bash
# Opt-in Compute Optimizer
aws compute-optimizer update-enrollment-status \
  --status Active
 
# Get recommendations
aws compute-optimizer get-ec2-instance-recommendations \
  --instance-arns arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0

Cost Allocation Tags

¿Qué son? Tags usados para tracking costs por project/team/environment.

Tag Strategy

plaintext
Common tags:
- Environment: prod, dev, test
- Project: website, mobile-app, analytics
- Team: engineering, marketing, sales
- CostCenter: CC-1234
- Owner: juan@empresa.com
 
Example:
Resource: ec2-web-server-prod-1
Tags:
  Environment: production
  Project: website
  Team: engineering
  CostCenter: CC-1234

Cost Allocation Report

plaintext
Activate tags:
1. Billing Console → Cost Allocation Tags
2. Select tags to activate
3. Wait 24 hours for data
 
Generate report:
Filter by: Project = website
Result:
- EC2: $500
- RDS: $300
- S3: $100
Total website project: $900/month
 
Chargeback:
Engineering team charged $900 for website project

Savings Plans

¿Qué son? Flexible pricing model con commitment de gasto.

plaintext
vs. Reserved Instances:
 
Reserved Instances:
- Specific instance type
- Specific region
- Less flexible
- Up to 72% descuento
 
Savings Plans:
- Any instance type/size
- Any region
- Any OS
- Más flexible
- Up to 72% descuento

Tipos

1. Compute Savings Plans

plaintext
Most flexible:
- EC2, Fargate, Lambda
- Any instance family, size, OS, region
 
Example:
Commit: $10/hour por 1 año
Usage:
- t3.small en us-east-1
- m5.large en eu-west-1
- Lambda en ap-southeast-1
 
All get descuento

2. EC2 Instance Savings Plans

plaintext
Specific to EC2:
- Any size/OS dentro de instance family
- Specific region
- Higher discount que Compute SP
 
Example:
Commit: $5/hour M5 family en us-east-1
Usage:
- m5.large ✅
- m5.xlarge ✅
- m5.2xlarge ✅
- t3.large ❌ (different family)

Recommendations:

plaintext
AWS provee recommendations:
 
Current On-Demand spend: $1,000/month
Recommendation: $8/hour Compute Savings Plan
Commitment: 1 year, No Upfront
Savings: $360/year (30%)
Break-even: <12 months
 
Accept recommendation → instant savings

Reserved Instances

¿Qué son? Commitment de instance type específico.

plaintext
Types:
1. Standard RI
   - Cannot change instance type
   - Up to 72% descuento
   - Most savings
 
2. Convertible RI
   - Can change instance type
   - Up to 54% descuento
   - More flexible
 
Payment options:
- All Upfront: Max descuento
- Partial Upfront: Medium descuento
- No Upfront: Min descuento

RI Utilization Report:

plaintext
Cost Explorer → RI Reports
 
Metrics:
- Utilization: 85% (target: >80%)
- Coverage: 60% (% of usage covered by RIs)
 
Recommendations:
"Purchase 5 more t3.medium RIs"
Estimated savings: $200/month

Cost Optimization Checklist

plaintext
Monthly tasks:
 
✅ Review Cost Explorer
   - Identify cost trends
   - Find anomalies
 
✅ Check Budgets
   - Are we on track?
   - Adjust if needed
 
✅ Review Compute Optimizer
   - Apply rightsizing recommendations
   - Estimate savings
 
✅ Audit orphaned resources
   - Unused EBS volumes
   - Unattached Elastic IPs
   - Old snapshots
   - Idle load balancers
 
✅ Review RI/Savings Plans utilization
   - >80% target
   - Purchase more if needed
 
✅ Validate tags
   - All resources tagged?
   - Cost allocation accurate?
 
✅ Stop/terminate unused
   - Dev/test instances off-hours
   - Old environments

📝 Preparación para el Examen

Puntos Clave

Cost Explorer:

  • 📌 Visualización: Graphs de costos históricos
  • 📌 Forecasting: Predicción ML de costos futuros
  • 📌 Filtering: Por service, region, tag
  • 📌 RI Reports: Utilization y recommendations

Budgets:

  • 📌 Types: Cost, Usage, Reservation, Savings Plans
  • 📌 Alerts: Email/SNS en thresholds
  • 📌 Custom actions: Lambda automation

Optimization:

  • 📌 Compute Optimizer: Rightsizing recommendations
  • 📌 Anomaly Detection: Automatic spike detection
  • 📌 Tags: Cost allocation y chargeback
  • 📌 Savings Plans: Flexible, hasta 72% descuento

Preguntas de Práctica

Pregunta 1:

¿Qué tool analiza utilización de EC2 y recomienda rightsizing?

A) Cost Explorer B) AWS Budgets C) AWS Compute Optimizer D) Trusted Advisor

Success

Respuesta: C) AWS Compute Optimizer

Compute Optimizer usa ML para analizar usage patterns y recomendar optimal instance types.

D también es correcta (Trusted Advisor tiene cost optimization checks), pero Compute Optimizer es más específico para rightsizing.

Pregunta 2:

¿Cuál es más flexible: Reserved Instances o Savings Plans?

A) Reserved Instances B) Savings Plans C) Ambos iguales D) Ninguno

Success

Respuesta: B) Savings Plans

Savings Plans permite cambiar instance type, size, OS, region. Reserved Instances son más restrictivos (especialmente Standard RIs).


🎓 Resumen

  1. Cost Explorer: Visualiza y analiza spending
  2. Budgets: Set limits con alerts automáticas
  3. Anomaly Detection: ML detecta spikes
  4. Compute Optimizer: Rightsizing recommendations
  5. Savings Plans: Flexible pricing con descuentos
  6. Tags: Cost allocation para chargeback

⏭️ Próximo Post

Post #17: AWS Support Plans - Basic, Developer, Business, Enterprise.


Tags: #AWS #CloudPractitioner #CostExplorer #Budgets #CostOptimization #SavingsPlans #Certification

Written by Jhonny Lorenzo

Researcher at TrautsLab

Related Articles

Recent Articles

Comments