Sub topic 15
Multi-Region keys
This chapter assumes you know the KMS basics from earlier chapters: customer managed symmetric keys, aliases, key policies, and envelope encryption with data keys. It also assumes you have used the AWS CLI with more than one Region.
Why a single-Region key is not always enough
A normal KMS key lives in one Region. Ciphertext encrypted under it can only be decrypted by calling KMS in that same Region. That is a problem in three common cases:
- You replicate encrypted data to a second Region for disaster recovery. The copy cannot be read if the original Region is down.
- You run an active-active application in several Regions and want any Region to read any record.
- You use DynamoDB global tables or Aurora global databases and want each Region to decrypt locally, with low latency.
You could re-encrypt data at every hop, but that adds calls, cost, and delay. Multi-Region keys avoid this.
What a Multi-Region key is
A Multi-Region key is a set of KMS keys in different Regions that share the same key ID and the same key material. One key is the primary. The others are replicas. Ciphertext produced by one key can be decrypted by any other key in the set.
Each key is still a separate KMS resource, and each has its own:
- key policy
- aliases
- grants
- enabled or disabled state
- CloudTrail log entries
KMS does not call across Regions when you decrypt. The local replica does the work.
Creating and replicating a key
Multi-Region key IDs start with mrk-. Create the primary with --multi-region. You cannot turn an existing single-Region key into a Multi-Region key. You must create a new one.
aws kms create-key \
--region us-east-1 \
--multi-region \
--description "Tutorial multi-region key"
# Use the KeyId returned by create-key (it starts with mrk-)
aws kms replicate-key \
--region us-east-1 \
--key-id <mrk-key-id> \
--replica-region eu-west-1Run replicate-key against the primary's Region. The replica appears in the target Region with the same key ID.
Using the replica
An encrypt in one Region and a decrypt in another works with the same key ID in the call:
echo -n "hello" > msg.txt
aws kms encrypt \
--region us-east-1 \
--key-id <mrk-key-id> \
--plaintext fileb://msg.txt \
--query CiphertextBlob \
--output text | base64 --decode > msg.enc
aws kms decrypt \
--region eu-west-1 \
--ciphertext-blob fileb://msg.enc \
--key-id <mrk-key-id> \
--query Plaintext \
--output text | base64 --decodePass --key-id on decrypt when you cross Regions. The ciphertext records the key ID, but the replica ARN differs from the primary ARN only by Region, so naming the key avoids ambiguity.
Common errors
- Assuming policies are copied. A replica gets a default key policy, not the primary's. Set the policy on each replica, or the application role in the second Region will get
AccessDeniedException. - Assuming aliases are copied. Create the alias again in each Region.
- Forgetting that rotation is shared. Automatic rotation is enabled on the primary, and KMS synchronizes the new key material to replicas.
- Deleting the primary too early. You cannot delete a primary while replicas exist. Delete the replicas first, or change the primary to another Region with
update-primary-region. - Mixing encryption context. The same encryption context must be supplied on decrypt, even in another Region.
When not to use them
Multi-Region keys weaken data residency boundaries, because the same key material exists in several Regions. If a rule requires that key material stay in one Region, use single-Region keys. For most other cases, prefer single-Region keys unless you need cross-Region decryption.
Exercise
You encrypted data in us-east-1 with a Multi-Region key and replicated it to eu-west-1. A role in eu-west-1 gets AccessDeniedException when it calls Decrypt on the replica. What is the most likely cause, and how do you fix it?
Show answer
Policies are not copied to replicas. The replica has its own key policy, which does not allow the role. Update the replica's key policy (or add an IAM policy allowing kms:Decrypt on the replica ARN, if the key policy delegates to IAM) in eu-west-1.
Exercise
Can you convert an existing single-Region key into a Multi-Region key?
Show answer
No. The multi-Region property is set only at creation with --multi-region. You must create a new Multi-Region key and re-encrypt data that you want to move to it.