AWS / Security
Cleanup scripts instead of write access: how SnoozeDB proves a saving with CloudTrail
A cost tool that finds old snapshots and idle IP addresses usually wants permission to delete them. Security teams rightly ask why a third party should hold delete rights on production accounts. SnoozeDB takes another route: it writes the cleanup, you run it, and CloudTrail shows what happened.
Two problems with automatic cleanup
The first is access. Deleting a snapshot, releasing an Elastic IP or deregistering an image needs IAM actions that can destroy data. Granting them to a vendor role widens what an attacker could do with that role, and it is hard to scope them to only the resources that deserve deletion.
The second is proof. Most tools report savings as estimates: a resource was flagged, so its price counts as saved. Nobody checks whether the resource was actually removed, by whom, or whether it came back. Finance sees a number it cannot audit.
What SnoozeDB can and cannot do in your account
SnoozeDB works through a cross-account IAM role with an External ID. That role is not read-only: it starts and stops the resources you schedule and writes SnoozeDB's own tags. The AWS connection guide lists every action.
It holds none of the actions the cleanup needs. It cannot modify or delete volumes or snapshots, release addresses, delete container images or deregister images. Those changes are made with your own credentials, in CloudShell or a terminal you control.
How a cleanup script is built
On the Cost Recommendations page, an owner or admin selects open recommendations from one AWS account and chooses Generate cleanup script. MFA is required when the organization enforces it. The browser sends only the recommendation IDs; the server reads the targets from its own records and writes a bash script that calls the AWS CLI.
| Recommendation | Command in the script | CloudTrail event |
|---|---|---|
| gp2 EBS volume | aws ec2 modify-volume (to gp3) | ModifyVolume |
| Old EBS snapshot | aws ec2 delete-snapshot | DeleteSnapshot |
| Idle Elastic IP | aws ec2 release-address | ReleaseAddress |
| Untagged ECR image | aws ecr batch-delete-image | BatchDeleteImage |
| Unused AMI | aws ec2 deregister-image, then its snapshots | DeregisterImage |
Manual RDS snapshots have their own cleanup script, described in the RDS snapshot guide.
Preview first, then apply
Without arguments, the script only checks and reports. Each target is marked READY or SKIP with a reason. Nothing changes until you run it again with --apply and type the confirmation it asks for:
bash snoozedb-cleanup-2026-12-04.sh # preview, changes nothing
bash snoozedb-cleanup-2026-12-04.sh --apply # asks you to type: APPLY 3 CLEANUPSEvery line goes to a timestamped log file next to the script, so you keep a local record of what was done, skipped or failed.
What the script checks before each change
- The account. It compares
aws sts get-caller-identitywith the account the script was generated for, and stops before any change if they differ. - Production tags. A resource tagged
env,environment,stageortierwith the valueprod,production,prdorliveis skipped, whatever the case. If its tags cannot be read, it is skipped too. - The current state. The volume must still be gp2, the snapshot completed, the address unassociated, the image untagged. The check runs in the preview and again just before each change, because things move between the two.
- Images still in use. An AMI is skipped if it is shared with other accounts, used by an instance, a launch template version or a launch configuration. Each of its snapshots then gets its own tag check, and a snapshot that cannot be deleted is kept and logged.
The script never decides on its own to clean up more than the recommendations you selected. Generating a new script for the same recommendation replaces the previous one.
From estimate to verified saving
Each script sets a unique marker in the AWS CLI user agent, snoozedb- followed by a random token. AWS records that user agent in CloudTrail with every call the script makes.
When a later sync no longer sees the resource, SnoozeDB looks up the matching CloudTrail event with cloudtrail:LookupEvents. The event must have the expected name and service, name the resource, carry no error, and contain the script's marker. Only then is the saving recorded, at the estimate shown when the script was generated, dated from the event. The recommendation shows Verified with CloudTrail, with the principal who ran the script and the time.
No match means no saving. A resource that disappeared for another reason, or an Elastic IP that was associated again, records nothing. Run the script within 30 days of generating it; after that, the recorded targets expire.
CloudTrail proves the change happened and who made it. The amount is still the estimate for that resource, not a figure read from your bill. Verified savings appear in the confirmed savings on the Metrics page.
What to tell your security team
- The SnoozeDB role cannot perform these cleanups. A person in your team runs every destructive call with their own credentials.
- The script is plain bash and AWS CLI. Read it before running it; the preview shows exactly what it would do.
- Verification needs only
cloudtrail:LookupEvents, in the Cleanup verification module. Without it, cleanups still work but no saving is recorded. - Generating a script and each verified saving are written to the SnoozeDB activity log.
Cost Recommendations are available on the Team, Startup and Scale plans. The cost recommendations guide describes each detector and the cleanup flow.