Lesson 3 of 4 AWS KMS

Sharing KMS Keys Across AWS Accounts

This lesson explains how to share encrypted data with another AWS account, which requires access to the KMS key as well as to the data. Both the owning account and the using account must grant that access.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain the two permissions that another account needs to use a customer managed key.
  • Identify the permissions needed in common cross-account scenarios, such as reading SSE-KMS objects.
  • Explain when a grant is preferable to a key policy change.

Two permissions are needed

Two things are needed for another account to use a customer managed key:

  1. The key policy in the owning account allows that account or a role in it.
  2. An IAM policy in the using account grants its principals the actions, such as kms:Decrypt, on the key's ARN.

The key policy statement in account A (111122223333) for account B (222233334444):

{
  "Sid": "AllowAccountBUseOfKey",
  "Effect": "Allow",
  "Principal": {"AWS": "arn:aws:iam::222233334444:root"},
  "Action": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"],
  "Resource": "*"
}

The identity policy attached to the role in account B:

{
  "Effect": "Allow",
  "Action": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"],
  "Resource": "arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}

Cross-account calls must use the key ARN; an alias in another account cannot be used.

Common cross-account scenarios

In practice, a KMS key is rarely shared on its own; it protects data held in another service, so the other account needs access to both the data and the key.

To read SSE-KMS objects in another account's bucket, the bucket policy must allow the reading account, and the key permissions described above must allow kms:Decrypt; without the key permissions, the request fails with AccessDenied even though the bucket policy allows it. To share an encrypted EBS or RDS snapshot, the snapshot is shared with the other account, and the key that encrypted it must allow that account to use it; the receiving account then usually copies the snapshot and re-encrypts it with its own key.

For an encrypted SQS queue or SNS topic, any producer, whether a role in another account or an AWS service such as S3 or EventBridge sending notifications, needs kms:GenerateDataKey and kms:Decrypt on the queue's or topic's key, as well as permission in the queue or topic policy. Because a service principal can be granted these permissions only in a key policy that you control, such queues must use a customer managed key. The following table summarises the scenarios.

ScenarioWhat else is needed
Reading SSE-KMS objects from another account's bucketA bucket policy allowing the account, plus both KMS permissions
Sharing an encrypted EBS or RDS snapshotShare the snapshot, and allow the other account to use the customer managed key that encrypted it
Sending to an encrypted SQS queue or SNS topic in another accountThe queue or topic policy, plus kms:GenerateDataKey and kms:Decrypt on its key

AWS managed keys, such as aws/s3 or aws/ebs, cannot be used across accounts because their key policies cannot be changed. Data that must be shared has to be encrypted with a customer managed key, or re-encrypted with one.

Scenario questions

Share encrypted data

Exam skills 2.2.4 · 2.1.6

Practise sharing KMS-encrypted data with other accounts.

Log in to try this activity Interactive activities are free with an account.

Grants for temporary access

A grant gives a principal in another account use of a key for specific operations without editing the key policy, and can be retired when no longer needed. Grants take effect quickly and suit programmatic, short-lived delegation.

Worked example

Sharing encrypted data with another account

Account A stores reports in S3 encrypted with its customer managed key. A role in account B can read the bucket (the bucket policy allows it) but every download fails.

PermissionWhereStatus
Bucket policy allows account B's roleAccount APresent
Key policy allows account B to use the keyAccount AMissing
Account B's role allows kms:Decrypt on A's key ARNAccount BMissing

Both KMS permissions are needed: the key policy in the owning account and an IAM policy in the using account. An AWS managed key such as aws/s3 could never work here, because its key policy cannot be changed.

Check yourself

A role in account B has kms:Decrypt on a key in account A, but decryption fails. What else is needed?

Show answer

The key policy in account A must also allow account B or the role. Cross-account use needs both the key policy and an IAM policy in the account that uses the key.

Exam Tips

Remember for the exam

  • If another account cannot decrypt, allow it in the key policy and in that account's IAM policy.
  • Data encrypted with an AWS managed key cannot be shared across accounts; use a customer managed key.
  • Use the key ARN, not an alias, when calling KMS for another account's key.
  • S3 access across accounts with SSE-KMS needs the bucket policy and both KMS permissions.