Sub topic 3
Encrypting backups with KMS keys
This chapter assumes you can create a backup vault, understand IAM roles and policies, and know what an AWS KMS key is. It covers how AWS Backup encrypts recovery points and how to choose the key.
How encryption works in AWS Backup
Every backup vault has an AWS KMS key that encrypts the recovery points stored in it. You pick the key when you create the vault. You can't change it afterward.
Two points about the key choice matter in practice:
- Some services encrypt their own backups. For Amazon EBS, RDS, DynamoDB and similar resources, the backup keeps the encryption state of the source resource. If the source is encrypted, the recovery point is encrypted with the source's key, not the vault key.
- For resources that are not encrypted at the source, and for services that rely on the vault for encryption, AWS Backup uses the vault key.
Check the AWS Backup documentation for your resource type before you assume which key protects a given recovery point.
Choosing a key
| Key type | Who manages it | When to use it |
|---|---|---|
| AWS managed key (`aws/backup`) | AWS | Default. No key policy to maintain. |
| Customer managed key | You | You need control over the key policy, rotation, auditing, or cross-account sharing. |
The AWS managed key is simple but you can't edit its key policy. It also can't be shared with another account. A customer managed key is the usual choice if you plan to copy backups to another account.
Creating a vault with a customer managed key
Create the key first, then pass its ARN when you create the vault.
aws kms create-key \
--description "Key for app-vault recovery points"
aws backup create-backup-vault \
--backup-vault-name app-vault \
--encryption-key-arn <kms-key-arn>Replace <kms-key-arn> with the Arn value returned by the first command. If you leave out --encryption-key-arn, AWS Backup uses the AWS managed key.
Permissions the service role needs
The service role that AWS Backup assumes must be allowed to use the key. For a customer managed key, either the key policy or an IAM policy on the role has to allow these actions:
kms:DescribeKeykms:GenerateDataKeykms:Decryptkms:CreateGrant
The default service role policies cover the AWS managed key. With your own key, you usually need to add the role to the key policy.
Common errors
- Job fails with an access denied error. The service role isn't allowed to use the key. Add the role to the key policy and check that the key is in the same Region as the vault.
- Restore fails. Restoring needs
kms:Decrypton the key that protects the recovery point. If someone deletes or disables the key, you can't restore from those recovery points. - Copy to another account fails. The destination account needs permission to use the source key, or you must encrypt the copy with a key the destination controls. This comes up again in the chapter on cross-account copies.
Exercise
You create a vault with the default encryption settings and later decide you need a customer managed key so you can share copies with another account. Can you change the key on the existing vault? What do you do?
Show answer
No. A vault's encryption key is set at creation and can't be changed. Create a new vault with the customer managed key, point your backup rules at it, and copy or let existing recovery points age out of the old vault under their retention settings.