📋 In This Post
Lab Overview
Everyone has deleted the wrong photo. It is not a disaster, because the phone keeps it in a folder called Recently Deleted for thirty days. The safety net was there before you needed it, and nobody had to switch it on.
Most people carry that assumption into AWS. There is a Recycle Bin, so a deleted snapshot must sit in it for a while. There is not, unless you created a rule for it first, in that Region, before the delete. AWS is direct about this: if you delete a resource that matches no retention rule, "that resource is permanently deleted; it is not moved to the Recycle Bin".
So: one snapshot of one volume, and Delete pressed four times under four different conditions — nothing in place, a Recycle Bin rule in place, a governance lock, and a compliance lock. Every screen below is the console at the moment of the click.
Cloud Services and Concepts
| Service | Purpose here | What it is |
|---|---|---|
| Amazon EBS | One encrypted 8 GiB gp3 volume holding a 512 MiB payload with a known checksum — the thing being protected | Network-attached disks for EC2 instances |
| EBS snapshots | The backup under test. Incremental, stored in S3 that you never see, and restorable into a new volume | A point-in-time copy of a volume |
| Recycle Bin | The safety net, and the week's main finding: it is opt-in, Region by Region, and only protects deletes that happen after the rule exists | A holding area for deleted EBS resources, governed by retention rules |
| EBS snapshot lock | The stronger control. Governance mode for "don't delete this by accident", compliance mode for "you cannot delete this at all" | A WORM lock applied to an individual snapshot |
| Amazon Data Lifecycle Manager | Creates the snapshots on a schedule, selecting volumes by tag, and deletes them when the retention count is exceeded | Managed snapshot scheduling, no code to run |
| HCP Terraform | Builds the volume, the instance and the roles in the sandbox account over OIDC, so no AWS keys are stored anywhere | Hosted Terraform runs with short-lived credentials |
The rule has to exist before the delete
A Recycle Bin retention rule is not a setting on a snapshot. It is a standing rule in a Region that catches matching resources as they are deleted. Nothing about it is retroactive, which is the whole trap: the moment you want it is the moment it is too late to create it.
Two consequences follow, and both cost money rather than data. Once a snapshot is in the bin you cannot take it out early — AWS says plainly that you "can't manually delete a resource from the Recycle Bin", it leaves when its retention period expires. And while it waits, snapshots in the bin "are billed at the same rate as regular snapshots in your account". A thirty-day rule is a thirty-day bill for everything anyone deletes.
Two kinds of lock, and only one is reversible
A locked snapshot "can't be deleted by any user, regardless of their IAM permissions". The mode decides who can take that back.
Governance mode locks immediately, and anyone holding the right IAM permission can unlock it again. It stops accidents, not decisions.
Compliance mode has an optional cooling-off period of one to seventy-two hours during which you can still change your mind. After it expires — or straight away, if you asked for no cooling-off — the door closes: you "can't unlock the snapshot, change the lock mode, or decrease the lock duration". AWS states the consequence in one sentence worth reading twice: "The only way to delete a snapshot that is locked in compliance mode before its lock expires is to close the associated AWS account."
Lock duration runs from 1 day to 36,500 days. There is no shorter option, which matters more than it sounds.
Architecture and Workflow
The numbers in the diagram are the order things happen:
- Take the snapshot from the volume, in the console, so every setting on the form is visible.
- Let Data Lifecycle Manager take the rest. The
policy selects volumes by the tag
Backup=dailyand keeps three. The tag is the selector, so an untagged volume is simply not backed up, and nothing anywhere says so. - Restore and check the bytes. A volume that mounts proves nothing. The 512 MiB payload has to hash to the same SHA-256 it had on the original.
Then the four deletes, which are the bottom half of the diagram and the rest of this post.
Prerequisites
- An AWS account, and Terraform 1.10 or later.
- A Recycle Bin retention rule in the same Region you will delete in. Rules are Region-scoped, and a rule in another Region is not a safety net, it is a line on an invoice.
- IAM permissions for
ec2:LockSnapshotandec2:UnlockSnapshot, andrbin:*for the retention rules. Holding the unlock permission is what makes governance mode reversible. - An instance you can reach with Session Manager, to write the payload and hash it afterwards. No SSH key, no inbound port.
Implementation
What was deployed
| Resource | How many | Its job |
|---|---|---|
aws_ebs_volume | 1 | 8 GiB gp3, encrypted, tagged Backup=daily — the data under test |
aws_instance | 1 | t3.micro, writes the payload and hashes it, reachable only by Session Manager |
aws_volume_attachment | 1 | Attaches the volume at /dev/sdf |
aws_dlm_lifecycle_policy | 1 | Daily at 03:00 UTC, keep 3, selecting by tag |
aws_iam_role | 2 | The instance profile, and the role Data Lifecycle Manager assumes |
aws_security_group and its rule | 2 | Egress only — Session Manager dials out, nothing dials in |
| Instance profile and role attachments | 3 | Binding the two roles to their managed policies |
Eleven resources, and not one of them is a protection control. The snapshot, the retention rule, the locks, the deletes and the restore are all console work, and all of it is below.
Taking the snapshot
And the ones nobody takes by hand
Validation and Evidence
| Test | Expected | Actual | Status |
|---|---|---|---|
| Delete a snapshot, no retention rule | recoverable from the bin | permanently gone, no bin entry | ❌ |
| Delete a snapshot, rule in place | held in the bin | held, exit time one day later | ✅ |
| Recover it from the bin | back in the snapshot list | recovered, fully usable | ✅ |
| Delete a governance-locked snapshot | refused | refused: "The snapshot is locked" | ✅ |
| Restore a volume and compare the data | byte-identical | SHA-256 identical on both | ✅ |
| Lock a snapshot for less than a day | allowed, for a lab | refused — one day is the floor | ❌ |
| Take a snapshot out of the bin early | possible | no such action exists | ❌ |
Delete one, with nothing in place
The first row is the week. Here is the console at the moment it happens, with no retention rule in the Region:
Now switch the safety net on
Now the same delete, on an identical snapshot. Same console, same button, same typed word:
The stronger control
With the lock on it, the console offers the Delete button exactly as before, and then declines:
Does the backup actually restore?
5f3193a3…89983 — the same value the original
payload had. A volume that mounts is not evidence. This is.The one thing the console cannot do
The lock form offers a duration in whole days and says "Min: 1 Day". The API takes a timestamp instead, which looks like a way round it. A lock asked to expire two hours later:
Security and Cost
The volume is encrypted, and a snapshot inherits the volume's encryption, so the backup is encrypted without anyone choosing to encrypt it. The instance has no inbound rule at all: Session Manager is an outbound connection, so writing and hashing the payload needed no SSH key and no open port.
The account-level guardrail got stricter this week. The deny
service control policy at the organization root now refuses volumes
above 100 GiB, refuses the provisioned-IOPS types, caps IOPS at the
gp3 maximum, and denies ec2:ModifyVolume
outright. That last one is there because the size and type condition
keys do not apply to a resize: an 8 GiB volume could be grown to 200 GiB
with every other rule still in place.
What this means for a platform team
Two of the three protections here are bills as much as they are controls. A retention rule means every deleted snapshot keeps costing for the full retention period, with no way to stop it early, and a thirty-day rule across a busy account is a standing charge nobody decided to accept. A compliance lock is worse if it is set wrongly: the documented escape is closing the account.
So pick the retention period as a cost decision, not a safety one, and test a lock in governance mode before anyone types the word compliance.
Cost
$0.38 measured, read from Cost Explorer on
2026-12-02 once both usage days had stopped moving: the
t3.micro $0.20, the public IPv4 address on it $0.10,
every EBS volume and snapshot in the lab $0.04, AWS Config $0.03, tax
$0.02.
Read that order again. The subject of the week cost four cents. All the storage, every snapshot, the restore, the Recycle Bin, the locks — four cents out of thirty-eight. The public IPv4 address attached to the instance cost two and a half times more than the thing the lab was about, and it was never mentioned in any of the screens above.
The Config line is the one worth checking in your own account. This
account has a configuration recorder left over from an unrelated
project, recording exactly two resource types:
AWS::EC2::Instance and AWS::EC2::Volume. It
billed nothing at all for the seven days before this lab, because there
were none of either. Creating eleven resources and deleting them again
cost $0.03 in configuration items — nine percent of the week, from
a service this lab never used and never configured.
Troubleshooting and Lessons
Problem. A snapshot locked for a few hours, so that a short-lived environment can still be torn down the same evening.
Root cause. There is no such lock. The console offers whole days with a minimum of one, and the API, which takes a timestamp and looks like it would accept anything, answers "The ExpirationDate must be one day or more after the current date and time".
Resolution. Governance mode, which can be unlocked on the way out. Compliance mode belongs nowhere near a short-lived environment: it is a snapshot you keep paying for until its lock expires, and no permission shortens that.
Lesson. Check whether a control can be undone before you switch it on, not after. The minimum duration of a protection is part of its cost.
Problem. A snapshot that landed in the Recycle Bin could not be removed from it.
Root cause. That is the design. Resources leave the bin when their retention period expires, or when you restore them, and there is no third option.
Lesson. The retention period is the one number that matters, and it is chosen once, in advance, for everything the rule catches. Treat it as a budget line.
Cleanup and Key Takeaways
The retention rule had to be deleted before the snapshots, or they would have gone to the bin and billed for another day with no way to empty it. The order of a teardown is part of its cost.
Key takeaways
- The Recycle Bin is not on. A deleted snapshot is permanently deleted unless a retention rule already existed in that Region. There is no grace period and the confirmation dialog does not hint at one.
- Protection you can configure after the fact is not protection. Every control here only works if it was in place before the mistake.
- The bin is a bill. Snapshots in it are charged at the normal rate, and nothing takes them out early.
- Governance before compliance. Governance mode refuses the delete and can still be unlocked. Compliance mode refuses everyone, including you, and the documented way out is closing the account.
- Restores are proved with a checksum. A volume that attaches and mounts is not evidence that the data survived.
- The backup was not the expensive part. Every volume and snapshot came to four cents of a thirty-eight cent week. The public IP address on the instance cost more than twice that.
One sentence worth carrying to any backup, in any cloud: the question is not "can I take a backup", it is "what happens the moment someone deletes it", and the answer was decided before anyone pressed the button.
References
- The full lab guide — the runbook, the Terraform, and every console step with its screenshot
- Recycle Bin considerations — that a rule must exist before the delete, and that nothing can be taken out of the bin early
- Recycle Bin, and its pricing — resources in the bin are billed at the normal rate
- Snapshot lock concepts — governance and compliance mode, the cooling-off period, and the lock duration limits
- EBS snapshot lock — that a locked snapshot cannot be deleted by any user, whatever their permissions
- Terraform —
aws_dlm_lifecycle_policy
Comments