Bringing Your Own Key Material to AWS KMS
This lesson explains how KMS imports key material that an organisation generates itself or must keep outside AWS, and the responsibility the organisation takes on in return.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the steps for importing key material.
- Explain how imported material differs in durability and rotation.
- Decide when imported key material meets a requirement.
The import process
Some organisations must generate key material in their own hardware security modules, for example to meet a regulation, to keep a copy outside AWS, or to be able to withdraw the key from AWS at any time. KMS supports this with imported key material, often called bring your own key (BYOK). The key material is generated outside AWS and is protected in transit by wrapping it with a public key that KMS provides, so it is never exposed in plaintext. The import consists of the following steps.
-
Create the key
Create a KMS key with origin
EXTERNAL. -
Get the wrapping key
Download a wrapping public key and import token.
-
Import the material
Generate the key material, wrap it and import it, optionally with an expiration date.
Importing key material
How imported material differs
Imported key material gives the customer more control, but it also gives the customer more responsibility. KMS keeps the imported material in its HSMs, but AWS cannot regenerate it, so the customer must keep a secure copy outside AWS. The customer can also remove the material at any time, which makes all data encrypted under it unreadable until the same material is imported again. The following list describes the principal differences from key material generated by KMS.
- Durability is your responsibility: you must keep a copy.
- Material can be deleted immediately, with no waiting period, and re-imported later to restore access.
- Material can be given an expiration date, after which KMS deletes it.
- No automatic rotation: rotate on demand by importing new material, or move an alias.
The following diagram shows the import of key material into a KMS key and how deleting it acts as a kill switch.

AWS-generated or imported material?
When to choose imported material
Imported material suits requirements for an escrow copy of keys, for generating keys in the organisation's own HSMs, or for the ability to make data unreadable instantly. Where the requirement is that keys must never be held in AWS at all, an external key store is needed instead.
An instant kill switch for encrypted data
A company must be able to make its data in AWS unreadable immediately, and keep an escrow copy of the key in its own HSM. It creates a KMS key with external origin and imports material generated in its HSM:
KEY_ID=$(aws kms create-key --origin EXTERNAL --query KeyMetadata.KeyId --output text)
aws kms get-parameters-for-import --key-id $KEY_ID \
--wrapping-algorithm RSAES_OAEP_SHA_256 --wrapping-key-spec RSA_4096
# Wrap the key material with the returned public key in the on-premises HSM, then:
aws kms import-key-material --key-id $KEY_ID --encrypted-key-material fileb://wrapped.bin \
--import-token fileb://token.bin --expiration-model KEY_MATERIAL_DOES_NOT_EXPIRE
# In an emergency
aws kms delete-imported-key-material --key-id $KEY_IDDeletion takes effect immediately, unlike the 7 to 30-day wait for deleting a key. Importing the same material again from the escrow copy restores access, so the company keeps full control of durability as well as deletion.
Does imported key material rotate automatically?
Show answer
No. It is rotated on demand after new material is imported into the same key, or manually by moving an alias to a new key.
Exam Tips
Remember for the exam
- When key material must be deletable instantly, use imported key material.
- To keep an escrow copy of keys outside AWS, use imported key material.
- Imported key material does not rotate automatically.
- You are responsible for keeping a copy of imported material.
- Imported material can be given an expiration date.