libZSservicesZSamazonka-kmsZSamazonka-kms
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.KMS.ImportKeyMaterial

Description

Imports key material into an existing symmetric KMS 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 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 and if so, when. If you set an expiration date, KMS deletes the key material from the KMS key on the specified date, and the KMS key becomes unusable. To use the KMS key again, you must reimport the same key material. The only way to change an 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 state: Effect on your KMS key 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
Synopsis

Creating a Request

data ImportKeyMaterial Source #

See: newImportKeyMaterial smart constructor.

Constructors

ImportKeyMaterial' 

Fields

  • expirationModel :: Maybe ExpirationModelType

    Specifies whether the key material expires. The default is KEY_MATERIAL_EXPIRES, in which case you must include the ValidTo parameter. When this parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE, you must omit the ValidTo parameter.

  • validTo :: Maybe POSIX

    The time at which the imported key material expires. When the key material expires, KMS deletes the key material and the KMS key becomes unusable. You must omit this parameter when the ExpirationModel parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE. Otherwise it is required.

  • keyId :: Text

    The identifier of the symmetric KMS key that receives the imported key material. The KMS key's Origin must be EXTERNAL. This must be the same KMS key specified in the KeyID parameter of the corresponding GetParametersForImport request.

    Specify the key ID or key ARN of the KMS key.

    For example:

    • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
    • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

    To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

  • importToken :: Base64

    The import token that you received in the response to a previous GetParametersForImport request. It must be from the same response that contained the public key that you used to encrypt the key material.

  • encryptedKeyMaterial :: Base64

    The encrypted key material to import. The key material must be encrypted with the public wrapping key that GetParametersForImport returned, using the wrapping algorithm that you specified in the same GetParametersForImport request.

Instances

Instances details
Eq ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Read ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Show ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Generic ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Associated Types

type Rep ImportKeyMaterial :: Type -> Type #

NFData ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Methods

rnf :: ImportKeyMaterial -> () #

Hashable ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

ToJSON ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

AWSRequest ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Associated Types

type AWSResponse ImportKeyMaterial #

ToHeaders ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

ToPath ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

ToQuery ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

type Rep ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

type Rep ImportKeyMaterial = D1 ('MetaData "ImportKeyMaterial" "Amazonka.KMS.ImportKeyMaterial" "libZSservicesZSamazonka-kmsZSamazonka-kms" 'False) (C1 ('MetaCons "ImportKeyMaterial'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "expirationModel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ExpirationModelType)) :*: S1 ('MetaSel ('Just "validTo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe POSIX))) :*: (S1 ('MetaSel ('Just "keyId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "importToken") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Base64) :*: S1 ('MetaSel ('Just "encryptedKeyMaterial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Base64)))))
type AWSResponse ImportKeyMaterial Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

newImportKeyMaterial Source #

Create a value of ImportKeyMaterial with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:expirationModel:ImportKeyMaterial', importKeyMaterial_expirationModel - Specifies whether the key material expires. The default is KEY_MATERIAL_EXPIRES, in which case you must include the ValidTo parameter. When this parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE, you must omit the ValidTo parameter.

$sel:validTo:ImportKeyMaterial', importKeyMaterial_validTo - The time at which the imported key material expires. When the key material expires, KMS deletes the key material and the KMS key becomes unusable. You must omit this parameter when the ExpirationModel parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE. Otherwise it is required.

$sel:keyId:ImportKeyMaterial', importKeyMaterial_keyId - The identifier of the symmetric KMS key that receives the imported key material. The KMS key's Origin must be EXTERNAL. This must be the same KMS key specified in the KeyID parameter of the corresponding GetParametersForImport request.

Specify the key ID or key ARN of the KMS key.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

$sel:importToken:ImportKeyMaterial', importKeyMaterial_importToken - The import token that you received in the response to a previous GetParametersForImport request. It must be from the same response that contained the public key that you used to encrypt the key material.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

$sel:encryptedKeyMaterial:ImportKeyMaterial', importKeyMaterial_encryptedKeyMaterial - The encrypted key material to import. The key material must be encrypted with the public wrapping key that GetParametersForImport returned, using the wrapping algorithm that you specified in the same GetParametersForImport request.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

Request Lenses

importKeyMaterial_expirationModel :: Lens' ImportKeyMaterial (Maybe ExpirationModelType) Source #

Specifies whether the key material expires. The default is KEY_MATERIAL_EXPIRES, in which case you must include the ValidTo parameter. When this parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE, you must omit the ValidTo parameter.

importKeyMaterial_validTo :: Lens' ImportKeyMaterial (Maybe UTCTime) Source #

The time at which the imported key material expires. When the key material expires, KMS deletes the key material and the KMS key becomes unusable. You must omit this parameter when the ExpirationModel parameter is set to KEY_MATERIAL_DOES_NOT_EXPIRE. Otherwise it is required.

importKeyMaterial_keyId :: Lens' ImportKeyMaterial Text Source #

The identifier of the symmetric KMS key that receives the imported key material. The KMS key's Origin must be EXTERNAL. This must be the same KMS key specified in the KeyID parameter of the corresponding GetParametersForImport request.

Specify the key ID or key ARN of the KMS key.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

importKeyMaterial_importToken :: Lens' ImportKeyMaterial ByteString Source #

The import token that you received in the response to a previous GetParametersForImport request. It must be from the same response that contained the public key that you used to encrypt the key material.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

importKeyMaterial_encryptedKeyMaterial :: Lens' ImportKeyMaterial ByteString Source #

The encrypted key material to import. The key material must be encrypted with the public wrapping key that GetParametersForImport returned, using the wrapping algorithm that you specified in the same GetParametersForImport request.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

Destructuring the Response

data ImportKeyMaterialResponse Source #

See: newImportKeyMaterialResponse smart constructor.

Constructors

ImportKeyMaterialResponse' 

Fields

Instances

Instances details
Eq ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Read ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Show ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Generic ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

Associated Types

type Rep ImportKeyMaterialResponse :: Type -> Type #

NFData ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

type Rep ImportKeyMaterialResponse Source # 
Instance details

Defined in Amazonka.KMS.ImportKeyMaterial

type Rep ImportKeyMaterialResponse = D1 ('MetaData "ImportKeyMaterialResponse" "Amazonka.KMS.ImportKeyMaterial" "libZSservicesZSamazonka-kmsZSamazonka-kms" 'False) (C1 ('MetaCons "ImportKeyMaterialResponse'" 'PrefixI 'True) (S1 ('MetaSel ('Just "httpStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)))

newImportKeyMaterialResponse Source #

Create a value of ImportKeyMaterialResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:httpStatus:ImportKeyMaterialResponse', importKeyMaterialResponse_httpStatus - The response's http status code.

Response Lenses