aws_ecr_repository cost estimation
A container image registry. Priced per GB-month stored, with the first 500 MB free, plus data transfer charges.
An aws_ecr_repository is a managed container image registry. Pricing has two main parts.
First, storage. Container images are billed at $0.10/GB-month after the 500 MB free tier. A repository with 50 GB of image layers costs about $5/month. ECR uses content-addressable storage, so duplicate layers across images are deduplicated automatically.
Second, data transfer. Pulling images from ECR to compute in the same region is free. Cross-region pulls incur cross-region transfer fees. Pulls to the internet (e.g., self-hosted runners outside AWS) incur standard egress fees.
ECR Public is a separate service with different pricing: free storage for public images, paid egress for high volumes. The Terraform resource is aws_ecrpublic_repository.
Practical cost drivers: deep image histories (every build creates new layers), unused images that aren't garbage-collected via lifecycle policies, and large images that contain build dependencies that should be excluded.
c3x estimates the per-repository storage cost when expected storage is specified in c3x-usage.yml. Without that, ECR shows as $0 with a "depends on usage" note.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "aws_ecr_repository" "api" {
name = "api"
image_tag_mutability = "IMMUTABLE"
image_scanning_configuration {
scan_on_push = true
}
encryption_configuration {
encryption_type = "AES256"
}
}
resource "aws_ecr_lifecycle_policy" "api" {
repository = aws_ecr_repository.api.name
policy = jsonencode({
rules = [{
rulePriority = 1
description = "Keep only 10 latest images"
selection = {
tagStatus = "any"
countType = "imageCountMoreThan"
countNumber = 10
}
action = { type = "expire" }
}]
})
}Pricing dimensions
What you actually pay for when you provision aws_ecr_repository.
| Dimension | Unit | What's being charged |
|---|---|---|
| Storage | per GB-month | Sum of all image layer sizes across all images in the repository. First 500 MB/month free at account level. $0.10/GB-month |
| Data transfer to internet | per GB | Image pulls to compute outside AWS. Standard AWS egress rates apply. |
| Cross-region replication | per GB transferred | If aws_ecr_replication_configuration is set, replicated bytes are billed at cross-region rates. |
| Pulls to in-region compute | free | ECR to EC2/ECS/EKS/Lambda in the same region: no charge. $0 |
Optimization tips
Common ways to reduce aws_ecr_repository cost without changing the workload.
Set lifecycle policies to expire old images
Up to 90% of stored bytesWithout lifecycle rules, every build accumulates layers forever. Setting a policy to keep only the last 10 images can cut storage by 90% for active CI repositories.
Use multi-stage Dockerfiles
50-80% per imageEach layer in the final image gets stored. Multi-stage builds drop build-time dependencies (compilers, package managers, intermediate artifacts) from the final image, often shrinking images by 50-80%.
Use VPC Endpoints for EKS/ECS pulling
NAT processing feesECR pulls from private subnets without endpoints go through NAT Gateway. Adding ECR Interface Endpoints eliminates NAT processing fees on image pulls. See our NAT Gateway alternatives post.
Skip cross-region replication unless required
50% on replicated reposECR cross-region replication is right for DR or multi-region deployments. For single-region production, replication doubles storage cost without benefit.
FAQ
Why does c3x show ECR as $0?
ECR is usage-based. The repository resource doesn't include image sizes; storage is whatever your CI happens to push. Specify expected storage_gb on the repository in c3x-usage.yml for a meaningful estimate.
Does c3x include the 500 MB free tier?
Yes. c3x applies the 500 MB account-level free tier to the first ECR repository in an estimate. Larger accounts with many repos may slightly overestimate because the free tier is shared.
How do I find which repos are wasting storage?
Run aws ecr describe-images and sort by image age and size. Combine with aws ecr describe-repositories to find repositories without lifecycle policies. CloudWatch metrics expose RepositorySizeInBytes per repo.
ECR or Docker Hub for our images?
If you deploy on AWS, ECR is cheaper because in-region pulls are free. Docker Hub is fine for public images. Docker Hub's pull rate limits on free accounts can disrupt CI; private repos in Docker Hub aren't free either.
Related resources
Estimate this resource in your own Terraform
Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including aws_ecr_repository.