Sub topic 14
Protecting backups with Vault Lock and access policies
A backup that an attacker, a mistaken script, or a rushed administrator can delete does not protect you much. This chapter covers the two controls AWS Backup gives you to prevent that: Vault Lock, which enforces retention rules on a vault, and vault access policies, which are resource-based policies that restrict who can call which Backup actions on it.
It assumes you have created app-vault, written a backup plan with a Lifecycle setting, and know how IAM identity policies and resource policies combine.
What each control does
The two controls solve different problems and are usually used together.
| Control | What it enforces | Who it constrains | Can it be made permanent? |
|---|---|---|---|
| Vault Lock | Minimum and maximum retention for recovery points in the vault | Everyone, including the root user | Yes, in compliance mode |
| Vault access policy | Which principals may call which `backup:` actions on the vault | Principals named or matched in the policy | No, it can be edited or removed by anyone with permission |
Vault Lock is a guarantee about retention. An access policy is a permission rule. Anyone who can edit the policy can also remove its restrictions, so a policy alone does not protect against a compromised administrator.
How Vault Lock works
Vault Lock is configured per vault with three settings:
MinRetentionDays: no recovery point in the vault can be deleted, or have its retention shortened, below this age.MaxRetentionDays: no backup job or copy job may create a recovery point that is retained longer than this.ChangeableForDays: the length of the grace period. Setting it selects compliance mode.
The retention limits apply to the lifecycle values on the jobs that write into the vault. If your plan says DeleteAfterDays: 35 and the vault minimum is 7 and maximum is 365, the job succeeds. If the plan says DeleteAfterDays: 3, the job fails because it is below the minimum. A copy job from another Region or account into the locked vault is checked the same way.
If you set MaxRetentionDays, a job that requests no expiry (retain forever) is also rejected, because "forever" exceeds any maximum. Check every plan rule and every on-demand job that targets the vault before you set a maximum.
Governance mode and compliance mode
The mode depends on whether you pass --changeable-for-days.
| Row | Governance mode | Compliance mode |
|---|---|---|
| How to select | Omit `--changeable-for-days` | Set `--changeable-for-days` (3 to 36,500) |
| Can the lock be changed or removed? | Yes, by principals with the right IAM permissions | Only during the grace period. After that, never |
| Can AWS remove it? | Not applicable | No. Not even AWS Support or the root user |
| Typical use | Testing, internal guardrails | Regulatory retention requirements |
In compliance mode, the lock is mutable until the grace period ends. You can use this window to verify that your plans and copy jobs still succeed, and to delete the lock if they do not. Once the grace period ends, the configuration is fixed.
The describe-backup-vault response shows the state. Locked is true once a lock exists. In compliance mode the response also includes LockDate, the moment the lock becomes immutable.
Applying a lock
Use the command from the topic examples. First apply it in governance mode on a test vault so you can see the effect without risk.
aws backup put-backup-vault-lock-configuration \
--backup-vault-name app-vault \
--min-retention-days 7 \
--max-retention-days 365To move to compliance mode with a three-day grace period, run the same command with --changeable-for-days 3. Then inspect the result.
aws backup describe-backup-vault \
--backup-vault-name app-vault \
--query '{Locked:Locked,Min:MinRetentionDays,Max:MaxRetentionDays,LockDate:LockDate}'To remove a lock that is still removable (governance mode, or compliance mode within the grace period), run the following command.
aws backup delete-backup-vault-lock-configuration \
--backup-vault-name app-vaultAfter LockDate, this call fails.
Vault access policies
A vault access policy is a resource-based policy attached to one vault. You write it in the same JSON format as an S3 bucket policy. The most common use is to deny deletion of recovery points to everyone except a small break-glass role.
Save this as vault-policy.json. Replace the account ID and role name with your own.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyDeleteRecoveryPointExceptBackupAdmin",
"Effect": "Deny",
"Principal": "*",
"Action": "backup:DeleteRecoveryPoint",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:PrincipalArn": "arn:aws:iam::123456789012:role/BackupAdmin"
}
}
}
]
}Attach and read it back with these commands.
aws backup put-backup-vault-access-policy \
--backup-vault-name app-vault \
--backup-vault-access-policy file://vault-policy.json
aws backup get-backup-vault-access-policy \
--backup-vault-name app-vaultNote that the CLI parameter is --policy in some versions and --backup-vault-access-policy in others. Run aws backup put-backup-vault-access-policy help to confirm which your installed version expects.
In a cross-account design, the access policy on the destination vault must also allow the source account to copy in. The statement allows backup:CopyIntoBackupVault, typically with a condition such as aws:PrincipalOrgID so that only accounts in your organization qualify. Without it, copy jobs fail at the destination even if the source account's IAM permissions are correct.
How they combine
Think of the checks as layers, evaluated for each request:
- IAM identity policies and permission boundaries in the calling account.
- The vault access policy. An explicit
Denyhere wins over anyAllowelsewhere. - Vault Lock. This applies to the data itself: even an allowed caller cannot delete a recovery point younger than the minimum retention.
An access policy can stop a person from deleting a recovery point that Vault Lock would have allowed (for example, one past its minimum age). Vault Lock can stop a deletion that no policy forbids. Use the policy for "who", and the lock for "how long".
Common errors
- Backup job fails with a lifecycle error. The rule's
DeleteAfterDaysis outside the vault's min/max range, or the rule has no expiry while a maximum is set. Adjust the plan rule, not the vault. - Copy job into a locked vault fails. The copy's lifecycle is outside the destination vault's limits. Set the copy action's
Lifecycleexplicitly. - You cannot edit the lock. The grace period has ended in compliance mode. There is no workaround.
- You locked yourself out of policy edits. An overly broad
Denyonbackup:PutBackupVaultAccessPolicywith no exception for an admin role leaves you unable to correct it through that principal. Always exempt a recovery role, and test it. - The lock does not stop the account's other data. Vault Lock protects recovery points in that vault only. The source resources, plans, and other vaults are unaffected.
Exercise
A vault has MinRetentionDays=14 and MaxRetentionDays=90. A plan rule writes into it with DeleteAfterDays=120. What happens, and what is the fix?
Show answer
The backup job fails, because 120 days exceeds the vault's maximum retention. Change the rule's DeleteAfterDays to a value between 14 and 90. Changing the vault is only an option if the lock is still removable, so fixing the plan is the safer choice.
Exercise
You apply a lock with --changeable-for-days 3 on Monday and notice on Friday that the minimum retention is too high. Can you fix it? Why or why not?
Show answer
No. The grace period ended after three days, so the lock is now an immutable compliance lock. Neither you, the root user, nor AWS can change or remove it. The only option is to let recovery points expire at their retention dates and use a different vault for future backups.
Exercise
Why is a Deny statement in a vault access policy not enough on its own to protect backups from a compromised administrator?
Show answer
An administrator with permission to change the policy can edit or delete the Deny statement and then delete recovery points. Vault Lock in compliance mode removes that option, because the retention rule cannot be changed once the grace period ends.