Overview and What You Will Learn
AWS costs stay invisible until you look at them, and by then you have often overpaid for weeks. This topic covers the tools that make spend visible (Cost Explorer, Budgets, Anomaly Detection), the discounts that lower it (Savings Plans and Reserved Instances), and the habits that remove waste (tagging, scheduling, and avoiding hidden network charges). In the lab you query your own bill from the CLI, set alerts, and check for a free S3 endpoint.
By the end you will be able to:
- Explain the four parts of an AWS bill and which data transfer is free
- Use Cost Explorer to break spend down by service, tag, account and instance type
- Set Budgets and Cost Anomaly Detection so surprises reach you in hours, not at month end
- Compare Compute Savings Plans, EC2 Instance Savings Plans and Reserved Instances
- Decide how much to commit to, and in what order to optimise
- Avoid networking charges such as NAT Gateway processing and cross-AZ traffic
- Use Instance Scheduler, Trusted Advisor and Compute Optimizer for steady savings
Why This Matters in Production
A common story is an engineering team that doubles its EC2 fleet for a load test, forgets to scale back, and finds out only when the invoice arrives. Another is a startup whose NAT Gateway bill exceeds its EC2 bill because every S3 request is routed through NAT instead of a free VPC endpoint. Neither needs better engineering. Both need visibility, alerts and a few defaults.
Cost work also compounds. Discounts only apply to the spend you have already trimmed, so the order matters: see the spend, remove the waste, right-size what is left, and only then commit to a discount.
Core Principles
How Does AWS Bill You?
Your bill has four parts: compute, storage, data transfer and requests. Compute covers EC2 hours, Lambda invocations and container task time. Storage covers S3, EBS and snapshots per GB-month. Requests cover API calls, S3 GET and PUT requests, and KMS operations. Data transfer is the part teams most often miss.
- Free: traffic into AWS from the internet, and traffic between resources in the same AZ over private IPs
- Free: traffic to S3 or DynamoDB through a Gateway Endpoint, and data from AWS origins into CloudFront
- Charged: traffic out to the internet, traffic across AZs (billed in each direction), cross-Region traffic and NAT Gateway processing
Prices vary by Region and change over time, so use the AWS pricing pages or the Pricing Calculator for exact numbers.
RememberTraffic between two instances in the same AZ is free over private IPs, and the same traffic over public or Elastic IPs is billed. Use private addresses for internal calls.
What Is AWS Cost Explorer and What Can It Show?
Cost Explorer is the AWS console tool for charting, filtering and forecasting your spend. You can view costs by service, Region, linked account, tag, instance type and more, look at up to the last 13 months, and see a forecast for the next 12. Hourly and resource-level views are optional settings you turn on, and they are limited in how far back they go. Cost Explorer also surfaces rightsizing recommendations, which come from Compute Optimizer and must be enabled.
- Filter example: last 3 months of EC2 in ap-south-1 only
- Group example: this month's cost grouped by the Environment tag
- Use resource-level data to find the single most expensive instance, or instances running 24 hours a day that are only used in office hours
Common MistakeTagging resources and then finding the tags missing in Cost Explorer. Tags only appear in cost reports after you activate them as cost allocation tags in the Billing console, and they apply from the activation date forward.
How Do AWS Budgets Work?
Budgets watch actual or forecasted cost or usage against a limit you set and notify you when thresholds are crossed. You can alert at 80 percent and 100 percent of the amount, and also on forecasted overspend, which warns you before the money is spent. Budget actions can go further by applying a restrictive IAM or service control policy, or stopping instances, when a limit is hit.
| Budget type | Tracks |
|---|---|
| Cost | Dollar spend |
| Usage | Units such as EC2 hours or S3 GB |
| Savings Plans | Coverage or utilization |
| Reservation | RI coverage or utilization |
Set one account-level monthly budget and one per service for your three most expensive services. The first couple of budgets are free, and later ones carry a small charge, so check current pricing.
What Is Cost Anomaly Detection?
Cost Anomaly Detection is a free service that learns your normal spending pattern and alerts you when something unusual happens. A monitor watches a scope, such as each AWS service, a linked account, a cost category or a cost allocation tag. When spend deviates from the expected pattern by more than your threshold, it sends an email or SNS message. It works from billing data, so alerts typically arrive within about a day instead of instantly.
Normal: EC2 about $200-220 a dayThursday: EC2 jumps to $800Alert: EC2 spend is far above expected in ap-south-1Cause: a GPU instance left running overnightWhich Should You Choose: Savings Plans or Reserved Instances?
Savings Plans commit you to a dollar amount of compute per hour for 1 or 3 years in exchange for a discount, and Reserved Instances commit you to a specific instance configuration. Savings Plans are simpler and more flexible, so they are the default for most teams. Reserved Instances remain the main option for services such as RDS, ElastiCache, OpenSearch and Redshift, which Compute and EC2 Instance Savings Plans do not cover.
| Savings Plans | Reserved Instances | |
|---|---|---|
| Commitment | Dollars per hour | A specific configuration |
| Flexibility | High to medium | Lower |
| Applies automatically | Yes | Yes, to matching usage |
- Compute Savings Plans: Up to about 66 percent off. They apply to EC2 in any family, size, Region or OS, plus Fargate and Lambda, so the discount follows you when you change instance types or move Regions.
- EC2 Instance Savings Plans: Up to about 72 percent off, but tied to one instance family in one Region.
- Other plans: AWS also offers plans for SageMaker and for some database services, so check the current list.
- Payment options: All upfront, partial upfront or no upfront. No upfront has the lowest cash commitment, and all upfront has the best discount.
Spend above your commitment is billed at On-Demand rates, and Spot usage is not covered by Savings Plans. Savings Plans also do not reserve capacity, so use On-Demand Capacity Reservations if you must guarantee capacity in an AZ.
TipStart with a 1-year Compute Savings Plan, no upfront, sized to your steady baseline. Do not commit to your peak, because a commitment you do not use is still billed.
In What Order Should You Optimise AWS Cost?
Follow a fixed order so you do not commit to waste. First make spend visible with tags and budgets, then remove unused resources, then right-size, then schedule non-production, and only then commit with Savings Plans.
A commitment bought before right-sizing locks in the oversized fleet. Use the Savings Plans coverage and utilization reports afterwards to see whether the commitment is working, and add a second plan only when coverage of your steady baseline is low.
What Are the Quick-Win Savings Beyond Commitments?
A handful of fixes usually remove waste with little risk.
| Quick win | Why it saves |
|---|---|
| Delete unattached EBS volumes and old snapshots | Storage billed while idle |
| Release unused Elastic IPs and idle load balancers | Hourly charges |
| S3 lifecycle rules and Intelligent-Tiering | Moves cold data to cheaper classes |
| gp3 instead of gp2 EBS | Lower price per GB |
| Graviton instances where software supports it | Better price performance |
| Spot for fault-tolerant work | Large discount |
Which Networking Costs Catch Teams Out?
The three common surprises are NAT Gateway processing, cross-AZ traffic and outbound internet transfer. NAT Gateway bills per GB processed, so sending S3 or DynamoDB traffic through it is waste when a free Gateway Endpoint exists. Cross-AZ traffic is billed per GB in each direction, so chatty services in different AZs add up. Outbound internet transfer is billed per GB, and putting CloudFront in front of cacheable content cuts it.
Illustrative arithmetic at an example rate of $0.045 per GB: 10 TB of S3 traffic through NAT each month is roughly 10,000 GB times $0.045, or about $450, and it is $0 through a Gateway Endpoint. At an example cross-AZ rate of $0.01 per GB each way, 100 GB a day each direction is about $60 a month. Check your Region's real rates before estimating.
TipCreate S3 and DynamoDB Gateway Endpoints in every VPC from day one. They are free, and they remove NAT charges for that traffic.
How Does Instance Scheduler Cut Non-Production Cost?
Instance Scheduler on AWS is a deployable solution that starts and stops EC2 and RDS instances on a schedule that you choose with tags. Development environments rarely need to run overnight or at weekends.
Tag: Schedule=office-hoursRunning: Monday to Friday, 8 AM to 10 PM ISTBilled: about 300 of 720 hours a month, roughly 58 percent less computeStorage such as EBS keeps billing while instances are stopped. EventBridge Scheduler is a lighter alternative for simple start and stop jobs.
What Are Trusted Advisor and Compute Optimizer?
Trusted Advisor checks your account against best practices for cost, security, fault tolerance, performance and service limits. Free accounts get a limited set of checks, and the full cost optimization checks need a Business or higher support plan, so confirm what your plan includes. Compute Optimizer analyses utilization and recommends better sizes for EC2, EBS, Lambda and more, and its output also feeds Cost Explorer rightsizing.
Detailed Step-by-Step Practical Lab
This lab uses the CLI and the console in a real account. The Cost Explorer API bills per request, so run the queries a few times, not in a loop.
Step 1: Query last month's cost by service
aws ce get-cost-and-usage \ --time-period Start=2026-09-01,End=2026-10-01 \ --granularity MONTHLY \ --metrics UnblendedCost \ --group-by Type=DIMENSION,Key=SERVICE \ --query 'ResultsByTime[0].Groups[].[Keys[0],Metrics.UnblendedCost.Amount]' \ --output tableNote your top three services. In the console under Cost Explorer, also group by Usage type and filter on Data Transfer to see network charges.
Step 2: Activate a cost allocation tag
aws ce update-cost-allocation-tags-status \ --cost-allocation-tags-status TagKey=Environment,Status=ActiveTag your resources with Environment, Team and Project. After activation, Cost Explorer can group costs by these tags.
Step 3: Create a monthly budget
In the console, open Cost Management, then Budgets, then Create budget.
- Type: Cost budget, period monthly
- Amount: about 10 percent above your normal monthly spend
- Alert 1: 80 percent of actual spend, by email
- Alert 2: 100 percent of forecasted spend, by email
- Alert 3: 100 percent of actual spend, by email
Step 4: Enable Cost Anomaly Detection
aws ce create-anomaly-monitor \ --anomaly-monitor 'MonitorName=all-services-monitor,MonitorType=DIMENSIONAL,MonitorDimension=SERVICE'In the console, add an alert subscription for that monitor with your email address, an impact threshold such as $10, and a daily or individual alert frequency.
Step 5: Review a Savings Plans recommendation
aws ce get-savings-plans-purchase-recommendation \ --savings-plans-type COMPUTE_SP \ --term-in-years ONE_YEAR \ --payment-option NO_UPFRONT \ --lookback-period-in-days THIRTY_DAYSThe output shows a suggested hourly commitment and estimated savings. A lab account with little steady usage may return nothing, which is normal. Do not buy a plan until you have right-sized.
Step 6: Check for a free S3 Gateway Endpoint
aws ec2 describe-vpc-endpoints \ --filters Name=service-name,Values=com.amazonaws.ap-south-1.s3 \ --query 'VpcEndpoints[].[VpcEndpointId,VpcEndpointType,VpcId]' \ --output tableIf a VPC with private subnets has no result, create a Gateway Endpoint and attach it to the private route tables.
Production Best Practices & Common Pitfalls
- Tag everything and activate the tags: Use Environment, Team and Project so each team sees its own bill.
- Set budgets on day one: Include forecast alerts so you hear before the money is spent.
- Turn on Cost Anomaly Detection: It is free and catches mistakes early.
- Right-size before you commit: A Savings Plan on an oversized fleet locks in waste.
- Commit to your baseline, not your peak: Unused commitment is still billed.
- Use Compute Savings Plans first: Move to EC2 Instance Savings Plans only for very stable fleets.
- Create Gateway Endpoints: They are free and cut NAT charges.
- Schedule non-production: Stop dev and test environments outside working hours.
- Review monthly: Look at coverage, utilization, anomalies and the top five services.
Common MistakeRouting S3 traffic through a NAT Gateway. The free Gateway Endpoint takes minutes to create and removes the processing fee.
Common MistakeLeaving dev and staging instances running around the clock. A schedule recovers well over half of their compute cost.
Common MistakeSetting up budgets only after the first surprise invoice. Create them before you need them.
Quick Reference & Troubleshooting Commands
| Task | Command |
|---|---|
| Cost by service | aws ce get-cost-and-usage --time-period Start=<date>,End=<date> --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE |
| Cost forecast | aws ce get-cost-forecast --time-period Start=<date>,End=<date> --metric UNBLENDED_COST --granularity MONTHLY |
| Savings Plans utilization | aws ce get-savings-plans-utilization --time-period Start=<date>,End=<date> |
| Savings Plans coverage | aws ce get-savings-plans-coverage --time-period Start=<date>,End=<date> |
| Anomalies found | aws ce get-anomalies --date-interval StartDate=<date>,EndDate=<date> |
| List cost allocation tags | aws ce list-cost-allocation-tags |
| Problem | Likely cause and fix |
|---|---|
| Tag missing in Cost Explorer | Tag not activated for cost allocation. Activate it and wait. |
| Savings Plan utilization is low | Commitment above steady usage. Do not renew at that size. |
| Bill jumped with no change in compute | Data transfer or NAT processing. Group by usage type. |
| No anomaly alerts | No subscription on the monitor, or threshold too high. |
| Budget alert not received | Notification address not confirmed. Check email or SNS subscription. |
| Cost Explorer shows no data | Cost Explorer not enabled, or data not yet processed. Wait up to a day. |