Cloud
Cloud Cost Management — tagging, budgets, and killing a spend spike
A FinOps field guide: make every dollar attributable with tags, catch overspend with budgets and anomaly detection, then trace a sudden bill jump from service to account to the one resource behind it — and verify the daily run-rate actually drops. AWS-first with GCP equivalents.
Quick reference — reach for these first
aws ce update-cost-allocation-tags-status --cost-allocation-tags-status TagKey=env,Status=ActiveActivate cost-allocation tags so every line is attributable to an owner. Un-tagged spend can't be governed.aws budgets create-budget --account-id ACCOUNT_ID --budget file://budget.json --notifications-with-subscribers file://notify.jsonA monthly cap with an 80% actual + forecasted alert. Your floor against surprises.aws ce create-anomaly-monitor --anomaly-monitor file://monitor.jsonML baseline per service; alerts on deviation the moment it appears, no threshold guessing.aws ce get-rightsizing-recommendation --service AmazonEC2Find idle and oversized compute with estimated monthly savings per instance. The biggest recurring lever.aws s3api put-bucket-lifecycle-configuration --bucket BUCKET --lifecycle-configuration file://lifecycle.jsonTransition cold objects to IA/Glacier and expire them. Cap never-expiring logs the same way.Killing a 40% spend spike: service → account → resource → verify
Text equivalent: A six-stage left-to-right flow for investigating a sudden bill jump. Stage 1 Detect: the bill is up 40 percent, seen in daily Cost Explorer. Stage 2 group by service to find which service. Stage 3 group by account or project to find whose. Stage 4 isolate the one resource, typically a GPU instance, cross-AZ or internet egress, an unattached EBS volume, or never-expiring logs. Stage 5 remediate by stopping, tiering, or deleting the root cause. Stage 6, highlighted, verify the daily run-rate drops the next day. Below, the five standing levers: tag and allocate, budgets plus alerts, anomaly detection, rightsizing, and storage lifecycle.
Common tasks
Task · Command · What to check
| Task | Command | What to check |
|---|---|---|
| Activate cost-allocation tags so spend becomes attributable | aws ce update-cost-allocation-tags-status --cost-allocation-tags-status TagKey=env,Status=Active TagKey=team,Status=Active | aws ce list-cost-allocation-tags --status Active shows env and team |
| Close an allocation gap — tag an untagged resource | aws ec2 create-tags --resources INSTANCE_ID --tags Key=env,Value=prod Key=team,Value=TEAM | aws ec2 describe-tags --filters Name=resource-id,Values=INSTANCE_ID lists both tags |
| See where the money goes — group the month by service | aws ce get-cost-and-usage --time-period Start=START_DATE,End=END_DATE --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE | Groups sorted by Amount; top ~5 services ≈ 80% of the bill |
| Split cost by account/project to localize a spike | aws ce get-cost-and-usage --time-period START_DATE,End=END_DATE --granularity DAILY --metrics UnblendedCost --group-by Type=DIMENSION,Key=LINKED_ACCOUNT | One account's daily line shows the step-up; others are flat |
| Create a monthly budget with an 80% + forecast alert | aws budgets create-budget --account-id ACCOUNT_ID --budget file://budget.json --notifications-with-subscribers file://notify.json | aws budgets describe-budgets --account-id ACCOUNT_ID lists it with notifications |
| Turn on Cost Anomaly Detection for the account | aws ce create-anomaly-monitor --anomaly-monitor '{"MonitorName":"acct","MonitorType":"DIMENSIONAL","MonitorDimension":"SERVICE"}' | aws ce get-anomaly-monitors returns the monitor; add a subscription with get-anomaly-subscriptions |
| Pull rightsizing recommendations for EC2 | aws ce get-rightsizing-recommendation --service AmazonEC2 | RightsizingRecommendations[] lists Modify/Terminate targets + EstimatedMonthlySavings |
| Find idle spend — unattached EBS volumes | aws ec2 describe-volumes --filters Name=status,Values=available --query "Volumes[].{id:VolumeId,GiB:Size}" | List is empty, or you have a confirmed kill list |
| [DESTRUCTIVE] Snapshot then delete a confirmed-unused volume | aws ec2 create-snapshot --volume-id VOLUME_ID && aws ec2 delete-volume --volume-id VOLUME_ID | aws ec2 describe-volumes --volume-ids VOLUME_ID returns InvalidVolume.NotFound |
| Tier cold storage — add an S3 lifecycle rule | aws s3api put-bucket-lifecycle-configuration --bucket BUCKET --lifecycle-configuration file://lifecycle.json | aws s3api get-bucket-lifecycle-configuration --bucket BUCKET echoes the transitions |
| Cap never-expiring CloudWatch log retention | aws logs put-retention-policy --log-group-name LOG_GROUP --retention-in-days 30 | aws logs describe-log-groups --log-group-name-prefix LOG_GROUP shows retentionInDays=30 |
| Catch idle egress — list unassociated Elastic IPs | aws ec2 describe-addresses --query "Addresses[?AssociationId==null].PublicIp" | Empty list; any returned EIP bills hourly while unattached |
| (GCP) Create a billing budget with a 90% threshold alert | gcloud billing budgets create --billing-account=BILLING_ACCOUNT_ID --display-name="monthly" --budget-amount=1000USD --threshold-rule=percent=0.9 | gcloud billing budgets list --billing-account=BILLING_ACCOUNT_ID shows the budget |
A bill jumps 40% overnight — trace it to a forgotten GPU box
AWS
aws ce get-cost-and-usage --time-period Start=2026-11-01,End=2026-11-14 --granularity DAILY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE
# Amazon EC2 steps from ~$180/day to ~$430/day starting Nov 09aws ce get-cost-and-usage --time-period Start=2026-11-08,End=2026-11-14 --granularity DAILY --metrics UnblendedCost --group-by Type=DIMENSION,Key=LINKED_ACCOUNT
# Account 2222 (ml-sandbox) owns the entire +$250/dayaws ec2 describe-instances --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].{id:InstanceId,type:InstanceType,up:LaunchTime}"
# one p3.2xlarge (GPU) launched Nov 09, untaggedaws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=INSTANCE_ID --start-time 2026-11-09T00:00:00Z --end-time 2026-11-14T00:00:00Z --period 86400 --statistics Average
# Average CPU 0.4% across 5 days — abandonedaws ec2 stop-instances --instance-ids INSTANCE_ID
# StoppingInstances: pending — the GPU hourly charge stopsaws ce get-cost-and-usage --time-period Start=2026-11-14,End=2026-11-16 --granularity DAILY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE
# EC2 back to ~$180/day — the +$250/day is goneTroubleshooting — symptom → first check → next check
| Symptom | First check | Establishes | Next check |
|---|---|---|---|
| 20%+ of spend lands in an untagged / 'No tag key' bucket and can't be charged back | aws ce get-cost-and-usage ... --group-by Type=TAG,Key=env and read the untagged group | How much spend is un-attributable and which services carry it | Enforce tags with an SCP / Tag Policy, backfill tags on existing resources; note activated cost-allocation tags only apply going forward |
| Budget blew past 100% but no alert ever arrived | aws budgets describe-notifications-for-budget --account-id ACCOUNT_ID --budget-name NAME | Whether a notification + confirmed subscriber exists and the threshold/comparison is correct | Budgets refresh ~8–12h behind and fire once per threshold crossing; add a FORECASTED notification and confirm the SNS/email subscription |
| Spike with no new instances — cost is in 'Data Transfer' or 'Requests' | aws ce get-cost-and-usage ... --group-by Type=DIMENSION,Key=USAGE_TYPE (look for DataTransfer-Out, NatGateway-Bytes, Requests) | Whether it's internet egress, cross-AZ, NAT data processing, or raw API/request volume | Add VPC gateway/interface endpoints so S3/ECR skip the NAT, keep traffic same-AZ, put CloudFront/caching in front; NAT charges per-GB processed on top of egress |
| A rightsizing downsize dropped an instance and p99 latency spiked | CloudWatch CPU/memory + p99 on the smaller size vs the baseline window | Whether the new size is genuinely starved (CPU credits, memory, network) or the regression is unrelated | Roll back to the prior size or a different family; size to sustained p95, not the average; reserve burstable (t-family) for spiky low-baseline loads only |
| Reserved Instance / Savings Plan / CUD coverage is low or commitments sit unused | aws ce get-reservation-coverage and aws ce get-savings-plans-utilization | Whether you're under-covered (paying on-demand) or over-committed (paying for idle reservations) | Commit only to the steady-state baseline; prefer flexible Compute Savings Plans over zonal RIs; let utilization settle before buying more |
| The anomaly detector stayed silent through a real spike | aws ce get-anomaly-monitors and get-anomaly-subscriptions — confirm the monitor dimension and a subscriber | Whether a monitor covers that service and a subscription threshold sits below the spike size | Lower the subscription threshold (absolute $ or % impact), add a SERVICE-dimension monitor; remember it needs ~10 days of history to learn a baseline |
References
- AWS — Managing costs with Budgetsdocs.aws.amazon.com
- AWS — Detecting anomalies (Cost Anomaly Detection)docs.aws.amazon.com
- AWS — Optimizing cost with rightsizing recommendationsdocs.aws.amazon.com
- Google Cloud — Create, edit, or delete budgets and alertscloud.google.com
- Microsoft — Cost Management + Billing overviewlearn.microsoft.com
Examples are AWS-first (Cost Explorer `ce`, Budgets, Cost Anomaly Detection) with GCP noted where it differs. CAPS tokens (ACCOUNT_ID, INSTANCE_ID, VOLUME_ID, BUCKET, LOG_GROUP, BILLING_ACCOUNT_ID, START_DATE/END_DATE as YYYY-MM-DD) are placeholders. Cost Explorer and Budgets data lag ~8–24h and the anomaly detector needs ~10 days of history to model a baseline — so verify a fix by the next day's run-rate, not instantly.