Hunting zombie resources in the cloud: orphaned volumes, poorly sized NAT Gateways and logs kept forever
Ready-to-use commands to find forgotten volumes and IPs, reduce NAT Gateway costs with VPC Endpoints, set log retention and safely automate cleanup with Cloud Custodian.
FinOps$ aws ec2 describe-volumes --filters Name=status,Values=available▍Every cloud account more than a year old has zombies: resources nobody uses, nobody remembers exist, and that keep charging every month. Individually they look small — a few dollars for a volume here, an IP there — but added together they often account for a meaningful slice of the bill. And, unlike architecture optimizations, eliminating zombies doesn’t require changing any code.
The examples below use AWS, but the same zombies exist (under other names) on Azure and Google Cloud.
Zombie 1: orphaned EBS volumes
When an instance is terminated, its additional volumes aren’t always deleted. They’re left with available status — not attached to anything — and keep charging per provisioned GB.
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].{id:VolumeId,gb:Size,type:VolumeType,created:CreateTime}' \
--output table
While you’re at it, also look for:
- Old snapshots of volumes that no longer exist (and snapshots of deregistered AMIs);
- gp2 volumes that can migrate to gp3, which is usually cheaper and has configurable IOPS — the migration can be done without stopping the instance.
Zombie 2: unused public IPs
Since 2024, AWS charges for every public IPv4 address, including Elastic IPs that are allocated and not associated with anything:
aws ec2 describe-addresses \
--query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]' \
--output table
Also check whether instances in private subnets are receiving public IPs unnecessarily.
Zombie 3: poorly sized NAT Gateways
NAT Gateway charges per hour and per GB processed. The second part is the one that catches people off guard: all traffic from private instances to the internet — including to S3 and other AWS services — goes through it and pays per GB.
Signs of a poorly sized NAT:
- Usage types with
NatGateway-Bytesamong the largest items in Cost Explorer; - Pods or instances downloading container images, packages or S3 data in large volumes;
- Development environments with one NAT Gateway per availability zone.
Fix 1: VPC Gateway Endpoints for S3 and DynamoDB
Gateway Endpoints for S3 and DynamoDB are free and take that traffic off the NAT:
resource "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.${var.region}.s3"
vpc_endpoint_type = "Gateway"
route_table_ids = aws_route_table.private[*].id
}
For other services (ECR, CloudWatch, STS, Secrets Manager), there are Interface Endpoints, which have an hourly and per-GB cost — they pay off when traffic volume is high. Do the math first.
Fix 2: per-environment NAT architecture
- Production: one NAT per availability zone is usually the right call (resilience, and it avoids cross-zone traffic costs).
- Development and testing: a single shared NAT may be acceptable — or none at all, if the workloads don’t need to reach the internet.
Fix 3: nearby caches and registries
Use an image pull-through cache (such as ECR’s) and package mirrors inside the VPC to avoid downloading the same dependencies from the internet thousands of times a day.
Zombie 4: logs kept forever
By default, a CloudWatch log group is created with “never expire” retention. Every Lambda function, every service and every old test accumulates logs indefinitely — and you pay for both ingestion and storage.
Find the log groups without retention:
aws logs describe-log-groups \
--query 'logGroups[?!retentionInDays].[logGroupName,storedBytes]' \
--output table
Set retention according to actual needs (and to legal and audit requirements):
aws logs put-retention-policy \
--log-group-name /aws/lambda/process-orders \
--retention-in-days 30
Other log savings:
- Reduce volume at the source: debug logs in production and health checks logged every second are expensive;
- Infrequent access storage class for logs that are rarely queried;
- Export to S3 with lifecycle rules for anything that needs to be kept for years.
Zombie 5: the other usual suspects
- Load balancers without healthy targets (or without any targets at all);
- Databases with no connections for weeks — forgotten test environments;
- Incomplete multipart uploads in S3, which take up space without showing up in the normal object listing;
- Old images in ECR without a lifecycle rule;
- PR preview environments that were never torn down.
For incomplete uploads, a lifecycle rule solves the problem for good:
{
"Rules": [
{
"ID": "abort-incomplete-multipart",
"Status": "Enabled",
"Filter": {},
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
}
]
}
Cleaning up safely: the quarantine process
Deleting production resources based on a script is a recipe for an incident. Use a staged process:
- Identify and mark with a tag (e.g.,
cleanup-candidate=2026-11-24). - Notify the owner (via the
teamtag) or the account’s channel. - Back up when applicable (volume snapshot, database export).
- Disable before deleting: stop the instance, remove it from the load balancer. If nobody complains, great — if someone does, you’ve found the owner.
- Delete after the agreed period (e.g., 30 days).
Automating with Cloud Custodian
Doing this by hand once is useful; doing it continuously is what solves the problem. Cloud Custodian lets you describe governance rules in YAML and run them periodically:
policies:
- name: ebs-orphans
resource: aws.ebs
filters:
- State: available
- type: value
key: CreateTime
value_type: age
op: greater-than
value: 14
actions:
- type: mark-for-op
tag: custodian_cleanup
op: delete
days: 30
This policy marks volumes that have been detached for more than 14 days for deletion in 30 days — giving the owner time to speak up. A second policy, using the marked-for-op filter, carries out the deletion when the deadline passes.
Useful complements: AWS Config managed rules (such as those that check for unused volumes and log retention), Trusted Advisor, and Compute Optimizer for rightsizing recommendations.
Keeping the zombies from coming back
Cleaning up is good; not creating them is better:
- Mandatory tags and log retention enforced in the Pull Request, with shift-left governance;
delete_on_termination = trueon volumes that don’t need to outlive the instance;- An expiration date tag on temporary environments, with automatic cleanup;
- A monthly review of the largest unallocated cost items.
And only after this cleanup does it make sense to calculate Savings Plans and reservations — so you don’t lock in waste for years.
Checklist
-
availablevolumes and old snapshots reviewed - Unassociated Elastic IPs released
- S3/DynamoDB Gateway Endpoints in every VPC
-
NatGateway-Bytescost analyzed per VPC - Every log group with retention set
- Lifecycle rules on S3 buckets and ECR repositories
- Automated quarantine and cleanup policies running
Zombie resources don’t make noise. That’s why they survive — until someone decides to go looking for them.