Controlling Access to Keys with Key Policies and Grants
This lesson explains how controlling access to keys controls access to encrypted data, since every KMS key has a key policy and grants add temporary, programmatic permissions.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why every key has exactly one key policy.
- Describe when grants are used.
- Explain the permissions needed to use a key across accounts.
- Share an encrypted snapshot with another account.
Key policies
Every KMS key has exactly one key policy, a resource policy that is the primary access control for the key. Unlike most AWS resources, a KMS key cannot be used by anyone, even the account's administrators, unless its key policy allows it. The default key policy contains a statement that lets the account delegate access through IAM; without that statement, IAM policies alone cannot grant access to the key.
Well-designed key policies separate key administrators, who manage the key's settings but cannot use it, from key users, who can encrypt and decrypt but cannot change the key, which provides separation of duties. The kms:ViaService condition limits a key to use through particular services, for example only through Amazon S3 in one Region, so the key cannot be used directly.
Key policies
Grants
A grant gives a principal permission to use a key for specific operations, without editing the key policy, and can be retired when no longer needed. AWS services such as EBS and RDS create grants on your behalf when they use your keys.
Cross-account use
Using a KMS key from another account requires permissions on both sides. The key policy in the owning account must allow the other account, or specific roles in it, to use the key. In the other account, IAM policies must grant its principals the required actions, such as kms:Decrypt, on the key's ARN. If either side is missing, access is denied.
AWS managed keys cannot be shared with other accounts at all, because their key policies cannot be edited. Encrypted EBS snapshots, RDS snapshots and AMIs can therefore be shared only when they are encrypted with a customer managed key. To share a snapshot encrypted with an AWS managed key, it is first copied and re-encrypted with a customer managed key, and the copy is shared.
The following diagram shows how a snapshot encrypted with an AWS managed key is shared.

Sharing encrypted data
Sharing an encrypted snapshot with a DR account
An RDS snapshot encrypted with the AWS managed key aws/rds must be shared with a separate disaster recovery account. Sharing fails.
| Step | Action |
|---|---|
| 1 | Copy the snapshot, re-encrypting it with a customer managed key |
| 2 | Add a key policy statement allowing the DR account to use the key |
| 3 | Share the copied snapshot with the DR account |
| 4 | In the DR account, grant the restoring role KMS permissions on the key's ARN, then copy the snapshot with a local key |
AWS managed key policies cannot be changed, so cross-account sharing always needs a customer managed key. Copying the snapshot in the DR account with its own key removes the dependency on the source account's key.
When is a grant better than a key policy change?
Show answer
When a principal, often an AWS service, needs temporary, narrowly scoped use of a key. A grant can be created and retired programmatically without editing the key policy.
Exam Tips
Remember for the exam
- IAM policies can grant KMS access only if the key policy allows it.
- To share an encrypted snapshot across accounts, use a customer managed key and grant access in its key policy.
- To limit a key to use through one service, use the
kms:ViaServicecondition. - For separation of duties, give key administrators and key users different permissions.