Imports key material into an existing symmetric encryption KMS key that was created
without key material. After you successfully import key material into a KMS key, you can
reimport the same key material into that KMS key, but you cannot import different
key material.
You cannot perform this operation on an asymmetric KMS key, an HMAC KMS key, or on any KMS key in a different Amazon Web Services account. For more information about creating KMS keys with no key material
and then importing key material, see Importing Key Material in the
Key Management Service Developer Guide.
Before using this operation, call GetParametersForImport. Its response
includes a public key and an import token. Use the public key to encrypt the key material.
Then, submit the import token from the same GetParametersForImport
response.
When calling this operation, you must specify the following values:
The key ID or key ARN of a KMS key with no key material. Its Origin must
be EXTERNAL.
To create a KMS key with no key material, call CreateKey and set the
value of its Origin parameter to EXTERNAL. To get the
Origin of a KMS key, call DescribeKey.)
The encrypted key material. To get the public key to encrypt the key material, call
GetParametersForImport.
The import token that GetParametersForImport returned. You must use
a public key and token from the same GetParametersForImport response.
Whether the key material expires (ExpirationModel) and, if so, when
(ValidTo). If you set an expiration date, on the specified date, KMS
deletes the key material from the KMS key, making the KMS key unusable. To use the KMS key
in cryptographic operations again, you must reimport the same key material. The only way
to change the expiration model or expiration date is by reimporting the same key material
and specifying a new expiration date.
When this operation is successful, the key state of the KMS key changes from
PendingImport to Enabled, and you can use the KMS key.
If this operation fails, use the exception to help determine the problem. If the error is
related to the key material, the import token, or wrapping key, use GetParametersForImport to get a new public key and import token for the KMS key
and repeat the import procedure. For help, see How To Import Key
Material in the Key Management Service Developer Guide.
The KMS key that you use for this operation must be in a compatible key state. For
details, see Key states of KMS keys in the Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Imports key material into an existing symmetric encryption KMS key that was created without key material. After you successfully import key material into a KMS key, you can reimport the same key material into that KMS key, but you cannot import different key material.
You cannot perform this operation on an asymmetric KMS key, an HMAC KMS key, or on any KMS key in a different Amazon Web Services account. For more information about creating KMS keys with no key material and then importing key material, see Importing Key Material in the Key Management Service Developer Guide.
Before using this operation, call GetParametersForImport. Its response includes a public key and an import token. Use the public key to encrypt the key material. Then, submit the import token from the same
GetParametersForImport
response.When calling this operation, you must specify the following values:
The key ID or key ARN of a KMS key with no key material. Its
Origin
must beEXTERNAL
.To create a KMS key with no key material, call CreateKey and set the value of its
Origin
parameter toEXTERNAL
. To get theOrigin
of a KMS key, call DescribeKey.)The encrypted key material. To get the public key to encrypt the key material, call GetParametersForImport.
The import token that GetParametersForImport returned. You must use a public key and token from the same
GetParametersForImport
response.Whether the key material expires (
ExpirationModel
) and, if so, when (ValidTo
). If you set an expiration date, on the specified date, KMS deletes the key material from the KMS key, making the KMS key unusable. To use the KMS key in cryptographic operations again, you must reimport the same key material. The only way to change the expiration model or expiration date is by reimporting the same key material and specifying a new expiration date.When this operation is successful, the key state of the KMS key changes from
PendingImport
toEnabled
, and you can use the KMS key.If this operation fails, use the exception to help determine the problem. If the error is related to the key material, the import token, or wrapping key, use GetParametersForImport to get a new public key and import token for the KMS key and repeat the import procedure. For help, see How To Import Key Material in the Key Management Service Developer Guide.
The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Required permissions: kms:ImportKeyMaterial (key policy)
Related operations:
DeleteImportedKeyMaterial
GetParametersForImport
Use a bare-bones client and the command you need to make an API call.
import { KMSClient, ImportKeyMaterialCommand } from "@aws-sdk/client-kms"; // ES Modules import // const { KMSClient, ImportKeyMaterialCommand } = require("@aws-sdk/client-kms"); // CommonJS import const client = new KMSClient(config); const command = new ImportKeyMaterialCommand(input); const response = await client.send(command);
ImportKeyMaterialCommandInput for command's
input
shape.ImportKeyMaterialCommandOutput for command's
response
shape.config for KMSClient's
config
shape.