Importing key material step 4: Import the key material - Amazon Key Management Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Importing key material step 4: Import the key material

After you encrypt your key material, you can import the key material to use with an Amazon KMS key. To import key material, you upload the encrypted key material from Step 3: Encrypt the key material and the import token that you downloaded at Step 2: Download the public key and import token. You must import key material into the same KMS key that you specified when you downloaded the public key and import token.

When you import key material, you can optionally specify a time at which the key material expires. When the key material expires, Amazon KMS deletes the key material and the KMS key becomes unusable. To use the KMS key again, you must reimport key material.

After you successfully import key material, the KMS key's key state changes to enabled, and you can use the KMS key.

To import key material, you can use the Amazon Web Services Management Console or the Amazon KMS API. You can use the API directly by making HTTP requests, or by using an Amazon SDKs, Amazon Command Line Interface or Amazon Tools for PowerShell.

When you import the key material, an ImportKeyMaterial entry is added to your Amazon CloudTrail log to record the ImportKeyMaterial operation. The CloudTrail entry is the same whether you use the Amazon KMS console or the Amazon KMS API.

Import key material (console)

You can use the Amazon Web Services Management Console to import key material.

  1. If you are on the Download wrapping key and import token page, skip to Step 8.

  2. Sign in to the Amazon Web Services Management Console and open the Amazon Key Management Service (Amazon KMS) console at https://console.amazonaws.cn/kms.

  3. To change the Amazon Region, use the Region selector in the upper-right corner of the page.

  4. In the navigation pane, choose Customer managed keys.

  5. Choose the key ID or alias of the KMS key for which you downloaded the public key and import token.

  6. Choose the Cryptographic configuration tab and view its values. The tabs are on the detail page for a KMS key below the General configuration section.

    You can only import key material into KMS keys with a Key type of Symmetric and an Origin of EXTERNAL. For information about creating KMS keys with imported key material, see Importing key material in Amazon KMS keys.

  7. Choose the Key material tab and then choose Upload key material.

    The Key material tab appears only for KMS keys with a Key type of Symmetric and an Origin value of EXTERNAL.

  8. In the Encrypted key material and import token section, under Wrapped key material, choose Choose file. Then upload the file that contains your wrapped (encrypted) key material.

  9. In the Encrypted key material and import token section, under Import token, choose Choose file. Upload the file that contains the import token that you downloaded.

  10. In the Expiration option section, you determine whether the key material expires. To set an expiration date and time, choose Key material expires, and use the calendar to select a date and time.

  11. Choose Finish or Upload key material.

Import key material (Amazon KMS API)

To use the Amazon KMS API to import key material, send an ImportKeyMaterial request. The following example shows how to do this with the Amazon CLI.

This example specifies an expiration time for the key material. To import key material with no expiration, replace KEY_MATERIAL_EXPIRES with KEY_MATERIAL_DOES_NOT_EXPIRE and omit the --valid-to parameter.

To use this example:

  1. Replace 1234abcd-12ab-34cd-56ef-1234567890ab with the key ID of the KMS key that you used when you downloaded the public key and import token. To identify the KMS key, use its key ID or ARN. You cannot use an alias for this operation.

  2. Replace EncryptedKeyMaterial.bin with the name of the file that contains the encrypted key material.

  3. Replace ImportToken.bin with the name of the file that contains the import token.

$ aws kms import-key-material --key-id 1234abcd-12ab-34cd-56ef-1234567890ab \ --encrypted-key-material fileb://EncryptedKeyMaterial.bin \ --import-token fileb://ImportToken.bin \ --expiration-model KEY_MATERIAL_EXPIRES \ --valid-to 2019-09-17T12:00:00-08:00