Pricing & Billing
How AWS pricing actually adds up: per-service models, the bill mechanics, and the controls every team should turn on before launching.
AWS — pricing in practice
EXAMPLE
# ===== The big four pricing dimensions =====
# 1. Compute time (EC2 / Lambda / Fargate / RDS / EKS nodes)
# 2. Storage size (S3, EBS, RDS volume)
# 3. Data transfer (egress to internet, cross-AZ, cross-region)
# 4. Requests / ops (S3 requests, API Gateway calls, CloudWatch ingestion)
# Forget any one and the bill surprises you.
# ===== Common gotchas (where bills bloat) =====
# - NAT Gateway data processing: ~AUD 0.045/GB AFTER hourly fee -> reach for VPC endpoints
# - Cross-AZ data transfer between EC2 instances -> place comms in same AZ when possible
# - CloudWatch Logs ingestion: ~AUD 0.50/GB -> filter or sample before sending
# - S3 'requests' on hot prefixes -> use multipart upload + lifecycle rules
# - Idle Elastic IPs -> charged when NOT attached
# - Spinning up an Aurora cluster and forgetting to stop it -> 24/7 charges
# ===== Pricing models per service (mental model) =====
# EC2: On-demand | Spot (~70-90% off, can be reclaimed) | Reserved/Savings Plans (1-3yr, 20-72% off)
# Lambda: per request + per ms of run time, rounded to ms
# RDS: DB instance hours + storage GB + IOPS + backup storage beyond DB size
# S3: storage tier (Standard/IA/Glacier) + GET/PUT/LIST + egress
# DynamoDB: On-demand (pay per read/write unit) | Provisioned (capacity)
# CloudFront: per GB out + per request, varies by region
# ===== Cost controls (turn on before launch) =====
# 1. AWS Budgets: alarm at 50/80/100% of monthly target
aws budgets create-budget --account-id 1234 --budget '{
"BudgetName": "prod-monthly",
"BudgetLimit": { "Amount": "5000", "Unit": "AUD" },
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}'
# 2. Cost Anomaly Detection: ML-based; emails on shape changes
# Console: Cost Management -> Cost Anomaly Detection -> Create monitor
# 3. Tag enforcement at create-time
# Service Control Policies that REQUIRE 'project' + 'env' tags
{
"Effect": "Deny",
"Action": ["ec2:RunInstances", "rds:CreateDBInstance"],
"Resource": "*",
"Condition": {
"Null": { "aws:RequestTag/project": "true" }
}
}
# 4. CUR (Cost and Usage Report) in S3 + Athena queries
SELECT line_item_product_code, ROUND(SUM(line_item_unblended_cost), 2) AS aud
FROM cost.usage_report
WHERE billing_period_start = DATE '2024-04-01'
GROUP BY 1 ORDER BY 2 DESC;
# ===== Right-sizing levers =====
# - Compute Optimizer: free recommendations on EC2/EBS/Lambda
# - S3 Storage Lens: shows what's eating S3
# - Trusted Advisor (Business support+): idle resources, low utilisation
# - Graviton (arm64): often 20-40% cheaper for the same workload
# ===== Patterns to internalise =====
# - Tag everything from day one; without tags, all cost analysis is guesswork
# - Savings Plans for steady-state; Spot for batch
# - NAT Gateway suspicion: most VPC traffic should go via endpoints
# - CloudWatch ingestion is the silent bill driver
# - Right-size monthly, not yearly; workloads drift
# ===== Pitfalls =====
# - 'Free tier' applies only for 12 months and within tight limits
# - Forgetting AZ affinity -> cross-AZ chatter dominates the bill
# - Setting RDS storage = 'allocated forever' -> autoscaling helps but watch the upper bound
# - Personal account ('I'll just spin one up') with no budget alarm -> classic five-figure surprise
Why it matters
AWS pricing rewards three habits: tag at create-time, watch the four dimensions (compute, storage, transfer, requests), and lean on Savings Plans + Spot + Graviton when the workload allows. Budgets and Anomaly Detection are free safety nets — turn them on before you ship.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
# Almost everything is pay-as-you-go. # Use Budgets, Cost Explorer, and Savings Plans.Try it Yourself »
Discussion
Loading…