Sub topic 14
Protecting backups with Vault Lock and access policies
This chapter assumes you can create a backup vault and a backup plan, and that you know how IAM policies work. A backup only protects you if an attacker or a mistaken admin cannot delete it. AWS Backup gives you two controls for this: vault access policies and Vault Lock.
Two layers of protection
A vault access policy is a resource-based policy attached to one vault. You can use it to deny actions such as backup:DeleteRecoveryPoint. An administrator with enough permissions can still change or remove the policy.
Vault Lock goes further. It sets retention limits on the vault and can make those limits permanent.
| Control | Who can undo it | Main use |
|---|---|---|
| Vault access policy | Anyone allowed to edit the policy | Restrict who can delete or copy |
| Vault Lock, governance mode | Users with the right IAM permissions | Enforce retention, but keep an escape hatch |
| Vault Lock, compliance mode | No one, after the grace period | Immutable, WORM-style retention |
Denying deletes with an access policy
Save this as policy.json. It blocks manual deletion of recovery points for every principal.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyDeleteRecoveryPoints",
"Effect": "Deny",
"Principal": "*",
"Action": "backup:DeleteRecoveryPoint",
"Resource": "*"
}
]
}aws backup put-backup-vault-access-policy \
--backup-vault-name app-vault \
--policy file://policy.jsonEnabling Vault Lock
The lock sets a minimum and a maximum retention. Any backup job whose lifecycle falls outside that range is rejected.
aws backup put-backup-vault-lock-configuration \
--backup-vault-name app-vault \
--min-retention-days 7 \
--max-retention-days 365 \
--changeable-for-days 3The --changeable-for-days option selects the mode:
- Leave it out and the vault is in governance mode. You can change or remove the lock later.
- Set it (the minimum is 3) and the vault enters compliance mode. During the grace period you can still edit or remove the lock. When it ends, the lock is permanent.
Common errors
- Backup jobs fail after locking. A rule's
DeleteAfterDaysis below the minimum or above the maximum. Change the plan's lifecycle so it fits the lock range. - Locking in compliance mode too early. You cannot undo it after the grace period. Test in governance mode or in a non-production vault first, and use a long enough grace period to check your plans.
- Treating the access policy as immutable. It is only as strong as the permissions needed to edit it.
Exercise
A vault is locked in compliance mode with --min-retention-days 7. A rule writes to it with DeleteAfterDays set to 3. What happens, and how do you fix it?
Show answer
The backup job fails because the lifecycle is shorter than the vault's minimum retention. Change the rule's DeleteAfterDays to a value between the vault's minimum and maximum, for example 35.