Sub topic 15
Multi-Region keys
This chapter assumes you have read the earlier chapters on KMS key types, aliases, encryption context, key policies and rotation. You should be comfortable running AWS CLI commands in more than one Region and reading boto3 code.
The problem a Multi-Region key solves
A normal KMS key is tied to one AWS Region. Ciphertext produced under it can only be decrypted by calling KMS in that same Region. That restriction causes trouble when you:
- Copy encrypted data to another Region for disaster recovery and must be able to read it there without calling back to the original Region.
- Run an active-active application in two Regions that must read each other's ciphertext.
- Use client-side encryption, where the encrypted data key is stored with the data and moves wherever the data goes.
One workaround is to re-encrypt everything under a different key in the target Region. That costs extra KMS calls and creates a window in which the data is unreadable. A Multi-Region key (MRK) avoids this. It is a set of KMS keys in different Regions that share the same key ID and the same key material. Ciphertext from any key in the set can be decrypted by any other key in the set.
How the pieces fit together
The first key you create is the primary key. You then create replica keys from it in other Regions. A replica is a real KMS key in its own Region, with its own ARN. Replicas are created by copying the primary's key material over AWS's internal network, so you never handle the material yourself.
Multi-Region key IDs start with mrk-. The ID is identical in every Region, but the ARN contains the Region, so each key still has a distinct ARN.
What is shared and what is not
Replicas are not mirrors of every setting. KMS synchronizes only the cryptographic properties and treats each key as an independent resource for everything else.
| Property | Shared across the set? |
|---|---|
| Key ID (`mrk-...`) | Yes |
| Key material | Yes |
| Key spec and key usage (for example symmetric encrypt/decrypt) | Yes |
| Automatic rotation setting and rotated key material | Yes, controlled from the primary |
| Key policy | No, each key has its own |
| Aliases | No, create them separately in each Region |
| Grants | No |
| Tags and description | No |
| Key state (enabled, disabled, pending deletion) | No |
| CloudTrail events | No, each Region logs its own calls |
Because policies are not copied, a replica starts with the policy you pass at replication time, or the default key policy if you pass none. The primary's restrictions do not carry over. Forgetting this is a common way to end up with a replica that is more open, or more closed, than intended.
Creating a Multi-Region key
The multi-Region property is fixed when the key is created. You cannot convert an existing single-Region key into a Multi-Region key, and you cannot convert a Multi-Region key back.
# Create the primary key in us-east-1
aws kms create-key \
--multi-region \
--description "Tutorial multi-Region key" \
--region us-east-1
# Give the primary an alias in its own Region
aws kms create-alias \
--alias-name alias/tutorial-mrk \
--target-key-id <mrk-key-id> \
--region us-east-1
# Replicate to eu-west-1. Run this against the primary's Region.
aws kms replicate-key \
--key-id <mrk-key-id> \
--replica-region eu-west-1 \
--description "Replica for EU" \
--region us-east-1
# Create the alias again in the replica Region
aws kms create-alias \
--alias-name alias/tutorial-mrk \
--target-key-id <mrk-key-id> \
--region eu-west-1Using the same alias name in each Region lets application code say alias/tutorial-mrk and resolve to the local key wherever it runs. That is a convention you maintain yourself, since KMS does not create aliases on replicas.
Pass --policy to replicate-key to give the replica a specific key policy. Replication also needs permission on both sides: kms:ReplicateKey in the key policy of the primary, and kms:CreateKey in the IAM policy of the caller for the replica Region.
Decrypting in another Region
Symmetric ciphertext records the key ID that produced it. Because the ID is the same everywhere, the replica recognizes the ciphertext as its own. The encryption context must still match exactly, as it does in a single Region.
import boto3
PRIMARY_REGION = "us-east-1"
REPLICA_REGION = "eu-west-1"
CONTEXT = {"purpose": "demo"}
def encrypt_in_primary(plaintext: bytes) -> bytes:
kms = boto3.client("kms", region_name=PRIMARY_REGION)
resp = kms.encrypt(
KeyId="alias/tutorial-mrk",
Plaintext=plaintext,
EncryptionContext=CONTEXT,
)
return resp["CiphertextBlob"]
def decrypt_in_replica(ciphertext: bytes) -> bytes:
kms = boto3.client("kms", region_name=REPLICA_REGION)
resp = kms.decrypt(
CiphertextBlob=ciphertext,
EncryptionContext=CONTEXT,
)
return resp["Plaintext"]
if __name__ == "__main__":
blob = encrypt_in_primary(b"my secret")
print(decrypt_in_replica(blob))The same applies to envelope encryption. Store the KMS-encrypted data key next to your data. After the data and the encrypted data key are copied to another Region, call Decrypt there to recover the data key, then decrypt the data locally. No cross-Region KMS call is needed.
Operating the set
Rotation. Enable automatic rotation on the primary key. KMS synchronizes the new key material to the replicas, so ciphertext from any Region still decrypts. Do not plan to manage rotation per replica.
Changing the primary. update-primary-region promotes a replica to primary and demotes the old primary to a replica. Use it when the application's home Region moves. It is a management operation, so do not make an outage failover depend on it. Even if it is unavailable, replicas keep serving Encrypt and Decrypt.
Deletion. Each key is scheduled for deletion on its own, with the usual 7 to 30 day waiting period. You can delete a replica while the primary stays in use. A primary that still has replicas is not removed until the replicas are gone. It waits in the PendingReplicaDeletion state, which gives you a safety margin. Deleting every key in the set ends your ability to decrypt, so apply the same care as with a single key.
Cost. Each key in the set is billed as a separate KMS key, and requests are billed in the Region where they are made. Three Regions cost about three times the monthly key fee.
Limits. Multi-Region keys can be symmetric, asymmetric or HMAC keys. You cannot create them in a custom key store.
When not to use one
Choose a Multi-Region key only when you need the same ciphertext to be readable in several Regions. Two things argue against it:
- Data residency or isolation. A key set spans Regions by design. If a rule says that data from a given Region must be decryptable only there, use independent single-Region keys.
- Larger blast radius. If the key material is compromised, every Region is affected. Independent keys limit that damage, and Multi-Region keys do not.
A related gotcha concerns AWS services. They accept an MRK as a KMS key in the Region where they run. Whether a service uses the shared key ID to avoid re-encryption during cross-Region copy depends on the service, so check its documentation before assuming it does.
Exercise
You encrypt a file's data key with a Multi-Region primary key in us-east-1 and copy the ciphertext to eu-west-1. A replica exists there, but Decrypt fails with an access denied error. The primary key policy allows your role. What is the most likely cause, and how do you fix it?
Show answer
Key policies are not shared between a primary and its replicas. The replica has its own policy, which probably does not allow your role. Update the replica's key policy in eu-west-1 to allow the role the needed actions, such as kms:Decrypt, and keep the same encryption context condition if the primary uses one.
Exercise
A teammate says: "We created a single-Region key last year. Add --multi-region to it so we can use it in Frankfurt." Why does this not work, and what are two ways to proceed?
Show answer
The multi-Region property is set only at creation and cannot be added to an existing key. You can create a new Multi-Region key and re-encrypt the existing data under it, or you can keep the single-Region key and create separate keys in Frankfurt, accepting that ciphertext is not portable between Regions.