Sub topic 1
How AWS charges for data transfer
AWS bills for data transfer by the path the bytes take, not by the service that sends them. An EC2 instance, a Lambda function, and an RDS database can all send data to the same place and pay the same per-GB rate. This chapter covers the pricing rules the rest of the tutorial builds on: which directions are free, which are charged, and how the charge appears on your bill.
Prerequisites
This chapter assumes you know the following:
- What regions, Availability Zones (AZs), VPCs, and subnets are.
- How to launch an EC2 instance and use an S3 bucket from the console or CLI.
- What a private versus public IP address is, and the basics of routing.
No prior knowledge of AWS billing is needed. The dollar figures below are typical us-east-1 list prices. Rates differ by region and change over time, so confirm them on the AWS pricing pages before you plan around them.
The core rule: direction and destination
Data transfer pricing follows a few simple rules:
- Inbound traffic from the internet is free.
- Outbound traffic to the internet is charged per GB, with a tier discount at higher volumes.
- Traffic between AZs or regions is charged because it crosses AWS infrastructure boundaries.
- Traffic that stays inside one AZ over private IP addresses is free.
- Managed network services, such as NAT gateways and Transit Gateway, add their own per-GB processing charge on top of any transfer charge.
Most charges apply to the sender. Inter-AZ traffic is the main exception. It is billed on both sides, so each GB is charged once as outbound from the sending AZ and once as inbound to the receiving AZ.
Charge categories at a glance
The table shows typical us-east-1 list prices. Treat the numbers as examples.
| Path | Typical charge | Who pays |
|---|---|---|
| Internet to AWS (inbound) | Free | Nobody |
| AWS to internet (outbound) | First 100 GB/month free, then about $0.09/GB for the first 10 TB | Source resource's account |
| Between regions | About $0.02/GB | Source region |
| Between AZs, same region, private IP | About $0.01/GB each direction | Both sides (about $0.02/GB total) |
| Same AZ, private IP | Free | Nobody |
| Same AZ, using a public or Elastic IP | About $0.01/GB each direction | Both sides |
| Through a NAT gateway | About $0.045/GB processed plus about $0.045/hour | NAT gateway owner |
| EC2 or Lambda to S3 in the same region | Free for the transfer itself | Nobody |
| CloudFront to internet | Lower per-GB rate than EC2 egress, with a free monthly allowance | Distribution owner |
Egress means traffic leaving AWS, and the internet row above is the most common example. Other terms in the table:
- A Gateway endpoint is a VPC feature that gives private access to S3 or DynamoDB at no hourly or per-GB charge. Later chapters cover it in detail.
- Free tiers, such as the 100 GB of monthly internet egress, are aggregated across services in an account. The same 100 GB does not apply separately to each service.
Why the same-AZ rule has a catch
Same-AZ traffic is free only when it goes over private IP addresses. If instance A sends to instance B in the same AZ using B's public IPv4 address or Elastic IP, the traffic is billed at roughly the inter-AZ rate in each direction. This often happens by accident, for example when a service is configured with a DNS name that resolves to a public address instead of the private one.
Two practical consequences follow:
- Use private DNS names or private IPs for service-to-service calls inside a VPC.
- Do not assume "same AZ" alone means free. Check which IP address the connection uses.
A diagram of the paths
The diagram shows where an application server's traffic goes and which paths cost money.
The NAT gateway double charge
A NAT gateway lets instances in private subnets reach the internet. Traffic that passes through it can be billed twice:
- A processing charge for every GB the NAT gateway handles, in either direction.
- The normal data transfer charge for the underlying path. For example, outbound internet traffic is still billed at the internet egress rate.
Traffic from a private instance to S3 in the same region through a NAT gateway has no transfer charge, but you still pay the NAT processing fee. That is why a gateway endpoint for S3 is a common early fix. The NAT gateway also bills about $0.045 per hour per gateway whether or not it carries traffic.
Worked example: estimating a month
Suppose a service in one region has the following monthly traffic. For simplicity, treat 1 TB as 1,000 GB, and keep every volume below the 10 TB tier boundary.
- 5,000 GB to internet clients.
- 2,000 GB between application servers and a database in a different AZ.
- 1,000 GB from private-subnet instances through one NAT gateway to S3.
The script below applies the rates from the table.
INTERNET_FREE_GB = 100
INTERNET_RATE = 0.09 # USD per GB, first 10 TB tier
INTER_AZ_RATE = 0.01 # USD per GB, charged on each side
NAT_GB_RATE = 0.045 # USD per GB processed
NAT_HOURLY = 0.045 # USD per hour
HOURS_PER_MONTH = 730
def internet_cost(gb):
return max(gb - INTERNET_FREE_GB, 0) * INTERNET_RATE
def inter_az_cost(gb):
# Each GB is billed as outbound on one side and inbound on the other.
return gb * INTER_AZ_RATE * 2
def nat_cost(gb, gateways=1):
return gb * NAT_GB_RATE + gateways * NAT_HOURLY * HOURS_PER_MONTH
items = {
"Internet egress": internet_cost(5000),
"Inter-AZ": inter_az_cost(2000),
"NAT gateway": nat_cost(1000),
}
for name, cost in items.items():
print(f"{name:16} ${cost:8.2f}")
print(f"{'Total':16} ${sum(items.values()):8.2f}")The output is:
Internet egress $ 441.00
Inter-AZ $ 40.00
NAT gateway $ 77.85
Total $ 558.85Internet egress dominates. The NAT gateway line looks small, but $45 of it is processing for S3 traffic that a free gateway endpoint could carry. At 100 TB per month, that processing fee alone would be $4,500. Rates that look small per GB scale linearly, so check the largest volume first.
How the charges appear on your bill
Cost Explorer and the Cost and Usage Report (CUR) group transfer charges by usage type. The names are encoded, and you learn to read them quickly:
DataTransfer-Out-Bytes: outbound to the internet.DataTransfer-Regional-Bytes: traffic between AZs in the same region.USE1-USW2-AWS-Out-Bytes: traffic leaving us-east-1 toward us-west-2. The prefix names the source and destination regions.NatGateway-Bytes: data processed by a NAT gateway.NatGateway-Hours: the hourly charge for the gateway's existence.
A region prefix, such as USE1-, is added to most usage types. This is why the same category can appear under several names across regions. The later chapter on Cost Explorer shows how to group and filter on these names.
Common mistakes
- Assuming inter-AZ traffic is free. It costs about $0.02/GB in total, and chatty services across AZs, such as database replicas, caches, and Kafka brokers, can add up quickly.
- Using public endpoints for internal calls. Calling a service by its public DNS name can route traffic out and back in, or bill it at the inter-AZ rate even within one AZ.
- Forgetting that S3 requests from a private subnet may use a NAT gateway. Without a gateway endpoint, the route table sends S3 traffic there.
- Comparing prices across regions without checking the source. Charges attach to the sender, so the direction of a transfer decides which account and which region rate apply.
- Ignoring tiers. Internet egress rates drop at higher volumes, so a large account pays a lower blended rate than a small one.
Summary of the model
Think about each transfer by answering four questions:
- Does the traffic leave AWS, cross a region, cross an AZ, or stay in one AZ?
- Does it use private or public IP addresses?
- Does it pass through a managed network service that adds a per-GB charge?
- Who is the sender, and in which region?
The answers place the traffic in a row of the table above and give you its per-GB cost. The following chapters take each expensive row in turn and show how to find it and reduce it.
Exercise
An application in AZ A sends 3,000 GB per month to a database in AZ B of the same region over private IPs. At about $0.01/GB charged on each side, what is the monthly cost, and how does it change if both are moved to the same AZ?
Show answer
The cost is 3,000 GB x $0.01 x 2 = $60 per month, because each GB is billed as outbound from AZ A and inbound to AZ B. If both resources run in the same AZ and use private IPs, the transfer is free, so the cost drops to $0. The trade-off is lower availability, because a single-AZ placement can fail as one unit.
Exercise
Instances in a private subnet download 2,000 GB per month from S3 in the same region through a NAT gateway. S3-to-EC2 transfer in the same region is free. What do you pay for this traffic, and what removes the charge?
Show answer
You pay the NAT gateway processing fee: 2,000 GB x about $0.045/GB = about $90 per month, plus the hourly charge for the gateway. An S3 gateway VPC endpoint added to the subnet's route table sends the traffic directly to S3, so the NAT processing fee no longer applies to it. The endpoint itself has no hourly or per-GB charge.