Billing Surprises: Find What Is Costing Money

Sooner or later every cloud engineer gets the message: “Why is the AWS bill so high this month?” Tracing AWS unexpected charges is a matter of narrowing down, from the total to the service and Region, then to the usage type, then to the actual resource and whoever created it, and finally stopping it and putting an alarm in place.

You’ll query Cost Explorer by service, Region and usage type, set up Cost Anomaly Detection and build Find-Spenders.ps1 to sweep every Region for things that cost money. Then you create two classic leaks and hunt them down: a NAT gateway that leaves its Elastic IP behind, and a volume hiding in another Region.

TimeYou needBy the end you can
60 minutesLessons 4, 25, 36 and 56 done (tags, saat-trail, budgets, Find-Waste.ps1, Get-RecentChanges.ps1), signed in as saat-admin. Cost: about USD 0.05 (a NAT gateway for a few minutes, a tiny volume, and a few Cost Explorer API calls at USD 0.01 each).Break down costs in Cost Explorer by service, Region and usage type, read usage type names, set up Cost Anomaly Detection, sweep all Regions for running and orphaned resources, and trace a resource back to whoever created it.

What it is, in one line

AWS unexpected charges are costs nobody planned for, usually from resources left running or orphaned, sometimes in another Region, and you find them by narrowing from service to usage type to resource.

In Simple Words

The electricity bill

Your electricity bill doubles. You don’t guess; you check which room’s meter jumped and then which appliance in that room, and usually it’s a heater someone left on in the spare room nobody goes into. Cost Explorer is the meter for each room (service and Region), usage types are the appliances, and the sweep script walks through every room, including the ones you never visit. After that you fit a smart alert, so next time you hear about it within a day instead of at the end of the month.

Engineer's View

Where AWS costs show up

Cost Explorer groups costs by service, Region, usage type, tag and more. Its data is usually up to a day behind and each API call costs USD 0.01. Usage types name exactly what you paid for, with a Region prefix (APS3 is Mumbai), for example APS3-NatGateway-Hours, APS3-EBS:VolumeUsage.gp3 and APS3-PublicIPv4:IdleAddress. A lot of what surprises people lands under “EC2 – Other”: NAT gateways, EBS volumes and snapshots, public IPv4 addresses and data transfer.

Cost Anomaly Detection uses machine learning on your spending and sends an email or alert when a service jumps past a threshold you set. It works alongside Budgets (Lesson 36), which compare spending against fixed amounts. Untagged resources are hard to pin on anyone, which is why this course tags everything.

For a leak that’s happening today, don’t wait for the bill. List NAT gateways, unused Elastic IPs, unattached volumes, running instances, databases and load balancers in every enabled Region, and then use CloudTrail in that Region to see who created them. SCPs that limit Regions (Lesson 33) stop the “forgotten test in another Region” problem before it starts.

How it works, step by step

This is the narrowing path.

1Which service and Region?

Group the month’s cost by service and then by Region, and compare with last month to find the jump.

From an AWS bill to the resource behind it

2Which usage type?

Filter to that service and group by usage type. The names tell you whether you’re paying for hours, gigabytes, requests or addresses.

3Which resource, and who?

Find the resource in that Region (with the sweep script or the console), then ask CloudTrail who created it and why it’s still around.

4Know the usual suspects

A short list covers most surprises:

The usual suspects behind unexpected AWS charges

Fix the leak today, and then add a guardrail such as a budget, an anomaly alert, a tag rule or a Region limit.

✅ Checkpoint: You can explain what a usage type is, why many surprises appear as “EC2 – Other”, and why you sweep all Regions for today’s leaks.

Hands-on lab: trace costs and hunt two leaks

Before you run any command, double-check it

Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.

Sign in and add the Cost Explorer helper:

cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
$end = (Get-Date).ToString('yyyy-MM-dd'); $start = (Get-Date).AddDays(-30).ToString('yyyy-MM-dd')
function Get-CostBy([string]$Key, [string]$FilterFile) {
  $extra = if ($FilterFile) { @('--filter', "file://$FilterFile") } else { @() }
  $r = aws ce get-cost-and-usage --time-period "Start=$start,End=$end" --granularity MONTHLY --metrics UnblendedCost --group-by "Type=DIMENSION,Key=$Key" @extra --output json | ConvertFrom-Json
  $r.ResultsByTime | ForEach-Object { $_.Groups } | Group-Object { $_.Keys[0] } | ForEach-Object { [pscustomobject]@{ Name = $_.Name; USD = [math]::Round(($_.Group | ForEach-Object { [double]$_.Metrics.UnblendedCost.Amount } | Measure-Object -Sum).Sum, 2) } } | Sort-Object USD -Descending | Select-Object -First 5 | Format-Table -AutoSize
}

1See where the money went

Paste this whole block. It shows your top services and Regions for the last 30 days:

Get-CostBy SERVICE
Get-CostBy REGION

You should see something like this:

Name                                    USD
----                                    ---
Amazon Relational Database Service     4.82
EC2 - Other                            3.16
Amazon Elastic Compute Cloud - Compute 2.40
Amazon Virtual Private Cloud           1.12
AWS Key Management Service             0.61

Name           USD
----           ---
ap-south-1   11.48
global        0.49
ap-southeast-1 0.21

Your numbers depend on how many labs you’ve run. The SQL Server lessons push RDS near the top, and “EC2 – Other” is the line people don’t understand, so that’s where you look next.

2Look inside “EC2 – Other”

Paste this whole block:

'{ "Dimensions": { "Key": "SERVICE", "Values": ["EC2 - Other"] } }' | Set-Content ec2-other.json
Get-CostBy USAGE_TYPE ec2-other.json

You should see something like this:

Name                             USD
----                             ---
APS3-EBS:VolumeUsage.gp3        1.02
APS3-NatGateway-Hours           0.94
APS3-PublicIPv4:InUseAddress    0.53
APS3-EBS:SnapshotUsage          0.33
APS3-PublicIPv4:IdleAddress     0.21

Now the charges have names: gp3 volumes, NAT gateway hours (Lesson 9), public IPv4 addresses both in use and idle, and snapshots. An “idle address” is an Elastic IP attached to nothing, which is money for nothing.

AWS unexpected charges lab output: top services and usage types
Top services and EC2 – Other usage types, roughly like this.

3Turn on Cost Anomaly Detection

Paste this whole block with your own email address. If AWS has already created a services monitor, it reuses that one:

$email = 'you@example.com'
$mon = aws ce get-anomaly-monitors --query "AnomalyMonitors[?MonitorDimension=='SERVICE'].MonitorArn | [0]" --output text
if (-not $mon -or $mon -eq 'None') {
  '{ "MonitorName": "saat-service-monitor", "MonitorType": "DIMENSIONAL", "MonitorDimension": "SERVICE" }' | Set-Content monitor.json
  $mon = aws ce create-anomaly-monitor --anomaly-monitor file://monitor.json --query MonitorArn --output text
}
@{ SubscriptionName = 'saat-daily-anomalies'; MonitorArnList = @($mon); Subscribers = @(@{ Type = 'EMAIL'; Address = $email }); Frequency = 'DAILY'; ThresholdExpression = @{ Dimensions = @{ Key = 'ANOMALY_TOTAL_IMPACT_ABSOLUTE'; MatchOptions = @('GREATER_THAN_OR_EQUAL'); Values = @('5') } } } | ConvertTo-Json -Depth 6 | Set-Content sub.json
aws ce create-anomaly-subscription --anomaly-subscription file://sub.json --query SubscriptionArn --output text

You should see something like this:

arn:aws:ce::111122223333:anomalysubscription/1a2b3c4d-5e6f-7a8b-9c0d-e1f2a3b4c5d6

From now on, if any service’s spending jumps USD 5 or more above what’s normal for you, a daily email tells you which one. It stays on after this lesson.

AWS Cost Anomaly Detection with monitor saat-service-monitor and daily alert subscription saat-daily-anomalies
Cost Anomaly Detection after the lab: one monitor for all services and a daily email for any jump of USD 5 or more.

4Sweep every Region for things that cost money

Paste this whole block. Find-Spenders.ps1 stays in C:\aws-lab, and a full sweep takes a minute or two:

$fs = @'
param([string[]]$Regions)
if (-not $Regions) { $Regions = (aws ec2 describe-regions --query "Regions[].RegionName" --output text) -split '\s+' | Where-Object { $_ } }
$found = 0
foreach ($r in $Regions) {
  $checks = @(
    @('NAT gateway', (aws ec2 describe-nat-gateways --region $r --filter Name=state,Values=pending,available --query "NatGateways[].NatGatewayId" --output text)),
    @('Unused Elastic IP', (aws ec2 describe-addresses --region $r --query "Addresses[?AssociationId==null].PublicIp" --output text)),
    @('Unattached volume', (aws ec2 describe-volumes --region $r --filters Name=status,Values=available --query "Volumes[].[VolumeId,Size]" --output text)),
    @('Running instance', (aws ec2 describe-instances --region $r --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].[InstanceId,InstanceType]" --output text)),
    @('RDS instance', (aws rds describe-db-instances --region $r --query "DBInstances[].[DBInstanceIdentifier,DBInstanceStatus]" --output text)),
    @('Load balancer', (aws elbv2 describe-load-balancers --region $r --query "LoadBalancers[].LoadBalancerName" --output text)))
  foreach ($c in $checks) {
    foreach ($line in (($c[1] | Out-String) -split '\r?\n')) {
      if ($line.Trim() -and $line.Trim() -ne 'None') { '{0,-15} {1,-18} {2}' -f $r, $c[0], ($line -replace '\s+', ' ').Trim(); $found++ }
    }
  }
}
if ($found -eq 0) { "Nothing running or left behind in $($Regions.Count) Regions." }
'@
$fs | Set-Content C:\aws-lab\Find-Spenders.ps1
.\Find-Spenders.ps1

You should see something like this:

Nothing running or left behind in 17 Regions.

Anything in the list you didn’t expect is your leak. Running this before you log off each day is about the cheapest habit you can have in the cloud.

✅ Checkpoint: You’ve seen your top services, Regions and EC2 – Other usage types, Cost Anomaly Detection has a daily subscription, and Find-Spenders.ps1 swept every enabled Region.

Break It, Then Fix It

Here are two leaks that catch almost everyone at least once.

1Break it: the NAT gateway and its Elastic IP

Create a NAT gateway for a “quick test”, then delete it the way most people do:

$alloc = aws ec2 allocate-address --domain vpc --tag-specifications 'ResourceType=elastic-ip,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=68}]' --query AllocationId --output text
$nat = aws ec2 create-nat-gateway --subnet-id $v.PublicA --allocation-id $alloc --query NatGateway.NatGatewayId --output text
aws ec2 wait nat-gateway-available --nat-gateway-ids $nat
.\Find-Spenders.ps1 -Regions ap-south-1
aws ec2 delete-nat-gateway --nat-gateway-id $nat | Out-Null
aws ec2 wait nat-gateway-deleted --nat-gateway-ids $nat
.\Find-Spenders.ps1 -Regions ap-south-1

You’ll get something like this:

ap-south-1      NAT gateway        nat-0a1b2c3d4e5f60718
ap-south-1      Unused Elastic IP  13.234.10.20

The NAT gateway is gone but its Elastic IP is still allocated, sitting idle and charged every hour until somebody notices. In Cost Explorer it turns up weeks later as PublicIPv4:IdleAddress. Fix: release the address as well:

aws ec2 release-address --allocation-id $alloc
.\Find-Spenders.ps1 -Regions ap-south-1

You should see this:

Nothing running or left behind in 1 Regions.

2Break it: a leak in another Region

Create a small volume in Singapore, the way a test in the “wrong” Region would, and then check with the Mumbai-only tool from Lesson 36:

$vol = aws ec2 create-volume --region ap-southeast-1 --availability-zone ap-southeast-1a --size 1 --volume-type gp3 --tag-specifications 'ResourceType=volume,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=68}]' --query VolumeId --output text
.\Find-Waste.ps1
.\Find-Spenders.ps1
Start-Sleep 300
.\Get-RecentChanges.ps1 -Region ap-southeast-1 -Minutes 15

You’ll get something like this:

No waste found in ap-south-1.
ap-southeast-1  Unattached volume  vol-0abc1234def567890 1
Time     Who        Action           Error
----     ---        ------           -----
11:02:14 saat-admin ec2/CreateVolume
Cost leaks: NAT gateway with leftover Elastic IP and a volume in another Region
Both leaks and their fixes, roughly like this.

The single-Region check saw nothing, but the all-Region sweep found the volume, and CloudTrail in that Region tells you who created it and when. In real life these leaks are often GPU instances or databases from a tutorial run in us-east-1. Fix: delete it (at work, check with its owner first):

aws ec2 delete-volume --region ap-southeast-1 --volume-id $vol
.\Find-Spenders.ps1 -Regions ap-southeast-1
Remove-Item ec2-other.json, monitor.json, sub.json -ErrorAction SilentlyContinue

You should see this:

Nothing running or left behind in 1 Regions.

✅ Checkpoint: You released an Elastic IP left behind by a deleted NAT gateway and found a volume in another Region with an all-Region sweep plus CloudTrail. Nothing from this lesson is left running; the anomaly subscription stays on.

This happened at work

The USD 2,300 weekend experiment

A student team at a college ran a GPU tutorial in us-east-1 because that’s the Region the guide used. They stopped the notebook but not the instance, and since their dashboards only looked at Mumbai, nobody saw it. Three weeks later the faculty account’s bill showed USD 2,300 under “Amazon Elastic Compute Cloud – Compute” in US East. Grouping Cost Explorer by Region found it in seconds, and CloudTrail in us-east-1 showed which student’s role had launched it. The instance was terminated within the hour, and AWS Support later knocked off part of the charge as a one-time courtesy. The college now has an SCP that allows only Mumbai, a USD 50 budget per team and Cost Anomaly Detection emails going to the lab coordinator.

Common mistakes and troubleshooting

MistakeWhat happensWhat to do
Looking only at your usual RegionLeaks elsewhere run for weeksGroup by Region; sweep all Regions
Deleting a NAT gateway but not its EIPIdle IPv4 charges continueRelease the Elastic IP too
Waiting for the monthly billWeeks of wasteBudgets plus Cost Anomaly Detection
Ignoring “EC2 – Other”NAT, EBS and IPv4 costs unexplainedGroup it by usage type
Untagged test resourcesNobody knows who owns themTag everything; report untagged
Deleting without askingBreaking something someone needsFind the owner in CloudTrail first

Interview questions

Click a question to open it. Each one is worded the way an interviewer would ask it, and underneath you’ll see why they ask it and one way you could answer in your own words.

Fresher level

1. Your manager asks why the AWS bill went up this month. How would you find out what’s costing money?

Why they ask this: They want to see that you can work down from a big number on the bill to one resource and the person who created it.

How you might answer: I’d open Cost Explorer and group by service, then by Region and usage type, which tells me what kind of charge it is and where. Then I’d find the actual resource in that Region and check CloudTrail to see who created it.

2. You see a big line called “EC2 – Other” on the bill. What is that?

Why they ask this: They’re checking that you know this confusing billing category, because a lot of common cost leaks hide inside it.

How you might answer: It’s the EC2-related charges that aren’t instance hours, so EBS volumes and snapshots, NAT gateways, public IPv4 addresses, data transfer and so on. When it grows, I group by usage type to see which of those it is.

3. What’s the difference between AWS Budgets and Cost Anomaly Detection, and would you use both?

Why they ask this: They want to see that you know which alert catches which kind of problem.

How you might answer: Budgets alert when spending or the forecast passes a fixed amount I’ve set, while Cost Anomaly Detection learns my normal spending and alerts on unusual jumps, even small ones. I’d use both, because a budget won’t notice a jump that’s still under the limit.

2–5 years experience

4. The bill jumped, but Cost Explorer shows nothing new for today. Why might that be?

Why they ask this: They want to know you understand that billing data is delayed and that you have another way to find the cause.

How you might answer: Cost data can lag by up to a day, so today’s charges may not be there yet. I don’t wait for it; I sweep the resources directly and check CloudTrail for anything created recently.

5. You deleted a NAT gateway to save money. What might still be costing you?

Why they ask this: They want to see that you know about the leftovers that keep billing after the main resource is gone.

How you might answer: The Elastic IP that was attached to it stays behind, and an idle public IPv4 address still costs money. Some route tables may also still point at the deleted gateway, so I’d release the Elastic IP and clean up those routes.

6. Someone ran up charges in a Region your company never uses. How would you stop that happening?

Why they ask this: They want to see that you prevent the problem with guardrails and still check in case something slips through.

How you might answer: I’d add SCPs that deny actions outside our approved Regions, so nobody can create new resources there. I’d also run sweeps across all Regions and keep cost reports grouped by Region, so anything left over still shows up.

Senior level

7. You’re asked to set up cost governance for 40 AWS accounts. How would you design it?

Why they ask this: They’re looking for a full approach to cost across many teams, covering visibility, ownership, alerts and regular reviews.

How you might answer: I’d use Organizations with consolidated billing, mandatory tags enforced by tag policies, and CUR data in Athena with dashboards on top. Each account or team would get budgets, anomaly detection would be switched on, and I’d add SCP Region limits and scheduled clean-up automation. Every month we’d review costs and rightsize with Compute Optimizer.

8. A developer left a large instance running for a month by mistake. What would you change afterwards?

Why they ask this: They want to see that you fix the process and not the person, so it doesn’t happen to anyone else.

How you might answer: I’d require an owner tag on every resource and add auto-stop schedules for non-production, like the one from Lesson 38. Budgets would alert the owner directly and anomaly alerts would catch sudden jumps. Then I’d run a blameless review, because anyone can forget an instance.

Quick quiz

Q1. Where do NAT gateway charges usually appear?

  1. RDS
  2. EC2 – Other
  3. S3
  4. IAM
Show answer

B — As NatGateway-Hours and data.

Q2. What was left after deleting the NAT gateway?

  1. A subnet
  2. Its Elastic IP
  3. A route table only
  4. Nothing
Show answer

B — Release it to stop idle IPv4 charges.

Q3. Why did Find-Waste.ps1 miss the Singapore volume?

  1. Bug
  2. It only checks Mumbai
  3. Volume was attached
  4. No permission
Show answer

B — Sweep all Regions.

Q4. What does APS3 in a usage type mean?

  1. A service
  2. The Mumbai Region
  3. An account
  4. A tag
Show answer

B — It is the Region prefix.

Q5. Which tool learns normal spending and alerts on jumps?

  1. Budgets
  2. Cost Anomaly Detection
  3. CloudTrail
  4. Config
Show answer

B — It uses machine learning.

Quick recap

  • Narrow down: service, Region, usage type, resource, owner.
  • “EC2 – Other” hides NAT, EBS, snapshots and public IPv4.
  • Cost data lags, so sweep all Regions to catch today’s leaks.
  • When you delete a NAT gateway, release its Elastic IP too.
  • Budgets, Cost Anomaly Detection and Region limits together prevent most surprises.

Next lesson

Lesson 69: Final project: build it, break it, fix it → You’ll build a small company’s stack on AWS from one template, then diagnose and fix 10 broken scenarios.

Further reading: AWS unexpected charges

Want to go deeper into AWS unexpected charges? Read Detecting unusual spend with AWS Cost Anomaly Detection and Analyzing your costs with AWS Cost Explorer. You can also see the full plan for this course on the AWS Cloud Administration course page.

Scroll to Top

This website uses cookies

We use a few cookies to keep this site working. If you allow it, we also use Google Analytics to count visits so we can improve our lessons. You can accept all, deny the optional ones, or choose what to allow.