CfnKeyProps

class aws_cdk.aws_kms.CfnKeyProps(*, key_policy, description=None, enabled=None, enable_key_rotation=None, key_spec=None, key_usage=None, multi_region=None, pending_window_in_days=None, tags=None)

Bases: object

Properties for defining a CfnKey.

Parameters:
  • key_policy (Any) –

    The key policy that authorizes use of the KMS key. The key policy must conform to the following rules. - The key policy must allow the caller to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, refer to the scenario in the Default key policy section of the AWS Key Management Service Developer Guide . - Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to AWS KMS . When you create a new AWS principal (for example, an IAM user or role), you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to AWS KMS . For more information, see Changes that I make are not always immediately visible in the AWS Identity and Access Management User Guide . If you are unsure of which policy to use, consider the default key policy . This is the key policy that AWS KMS applies to KMS keys that are created by using the CreateKey API with no specified key policy. It gives the AWS account that owns the key permission to perform all operations on the key. It also allows you write IAM policies to authorize access to the key. For details, see Default key policy in the AWS Key Management Service Developer Guide . A key policy document can include only the following characters: - Printable ASCII characters - Printable characters in the Basic Latin and Latin-1 Supplement character set - The tab ( \ u0009 ), line feed ( \ u000A ), and carriage return ( \ u000D ) special characters Minimum : 1 Maximum : 32768

  • description (Optional[str]) – A description of the KMS key. Use a description that helps you to distinguish this KMS key from others in the account, such as its intended use.

  • enabled (Union[bool, IResolvable, None]) – Specifies whether the KMS key is enabled. Disabled KMS keys cannot be used in cryptographic operations. When Enabled is true , the key state of the KMS key is Enabled . When Enabled is false , the key state of the KMS key is Disabled . The default value is true . The actual key state of the KMS key might be affected by actions taken outside of CloudFormation, such as running the EnableKey , DisableKey , or ScheduleKeyDeletion operations. For information about the key states of a KMS key, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide .

  • enable_key_rotation (Union[bool, IResolvable, None]) – Enables automatic rotation of the key material for the specified KMS key. By default, automatic key rotation is not enabled. AWS KMS supports automatic rotation only for symmetric encryption KMS keys ( KeySpec = SYMMETRIC_DEFAULT ). For asymmetric KMS keys and HMAC KMS keys, omit the EnableKeyRotation property or set it to false . To enable automatic key rotation of the key material for a multi-Region KMS key, set EnableKeyRotation to true on the primary key (created by using AWS::KMS::Key ). AWS KMS copies the rotation status to all replica keys. For details, see Rotating multi-Region keys in the AWS Key Management Service Developer Guide . When you enable automatic rotation, AWS KMS automatically creates new key material for the KMS key one year after the enable date and every year thereafter. AWS KMS retains all key material until you delete the KMS key. For detailed information about automatic key rotation, see Rotating KMS keys in the AWS Key Management Service Developer Guide .

  • key_spec (Optional[str]) – Specifies the type of KMS key to create. The default value, SYMMETRIC_DEFAULT , creates a KMS key with a 256-bit symmetric key for encryption and decryption. In China Regions, SYMMETRIC_DEFAULT creates a 128-bit symmetric key that uses SM4 encryption. You can’t change the KeySpec value after the KMS key is created. For help choosing a key spec for your KMS key, see Choosing a KMS key type in the AWS Key Management Service Developer Guide . The KeySpec property determines the type of key material in the KMS key and the algorithms that the KMS key supports. To further restrict the algorithms that can be used with the KMS key, use a condition key in its key policy or IAM policy. For more information, see AWS KMS condition keys in the AWS Key Management Service Developer Guide . .. epigraph:: If you change the value of the KeySpec property on an existing KMS key, the update request fails, regardless of the value of the `UpdateReplacePolicy attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value. > AWS services that are integrated with AWS KMS use symmetric encryption KMS keys to protect your data. These services do not support encryption with asymmetric KMS keys. For help determining whether a KMS key is asymmetric, see Identifying asymmetric KMS keys in the AWS Key Management Service Developer Guide . AWS KMS supports the following key specs for KMS keys: - Symmetric encryption key (default) - SYMMETRIC_DEFAULT (AES-256-GCM) - HMAC keys (symmetric) - HMAC_224 - HMAC_256 - HMAC_384 - HMAC_512 - Asymmetric RSA key pairs - RSA_2048 - RSA_3072 - RSA_4096 - Asymmetric NIST-recommended elliptic curve key pairs - ECC_NIST_P256 (secp256r1) - ECC_NIST_P384 (secp384r1) - ECC_NIST_P521 (secp521r1) - Other asymmetric elliptic curve key pairs - ECC_SECG_P256K1 (secp256k1), commonly used for cryptocurrencies. - SM2 key pairs (China Regions only) - SM2

  • key_usage (Optional[str]) – Determines the cryptographic operations for which you can use the KMS key. The default value is ENCRYPT_DECRYPT . This property is required for asymmetric KMS keys and HMAC KMS keys. You can’t change the KeyUsage value after the KMS key is created. .. epigraph:: If you change the value of the KeyUsage property on an existing KMS key, the update request fails, regardless of the value of the `UpdateReplacePolicy attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value. Select only one valid value. - For symmetric encryption KMS keys, omit the property or specify ENCRYPT_DECRYPT . - For asymmetric KMS keys with RSA key material, specify ENCRYPT_DECRYPT or SIGN_VERIFY . - For asymmetric KMS keys with ECC key material, specify SIGN_VERIFY . - For asymmetric KMS keys with SM2 (China Regions only) key material, specify ENCRYPT_DECRYPT or SIGN_VERIFY . - For HMAC KMS keys, specify GENERATE_VERIFY_MAC .

  • multi_region (Union[bool, IResolvable, None]) – Creates a multi-Region primary key that you can replicate in other AWS Regions . You can’t change the MultiRegion value after the KMS key is created. For a list of AWS Regions in which multi-Region keys are supported, see Multi-Region keys in AWS KMS in the ** . .. epigraph:: If you change the value of the MultiRegion property on an existing KMS key, the update request fails, regardless of the value of the `UpdateReplacePolicy attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value. For a multi-Region key, set to this property to true . For a single-Region key, omit this property or set it to false . The default value is false . Multi-Region keys are an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions . Because these KMS keys have the same key ID, key material, and other metadata, you can use them to encrypt data in one AWS Region and decrypt it in a different AWS Region without making a cross-Region call or exposing the plaintext data. For more information, see Multi-Region keys in the AWS Key Management Service Developer Guide . You can create a symmetric encryption, HMAC, or asymmetric multi-Region KMS key, and you can create a multi-Region key with imported key material. However, you cannot create a multi-Region key in a custom key store. To create a replica of this primary key in a different AWS Region , create an AWS::KMS::ReplicaKey resource in a CloudFormation stack in the replica Region. Specify the key ARN of this primary key.

  • pending_window_in_days (Union[int, float, None]) –

    Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack. Enter a value between 7 and 30 days. The default value is 30 days. When you remove a KMS key from a CloudFormation stack, AWS KMS schedules the KMS key for deletion and starts the mandatory waiting period. The PendingWindowInDays property determines the length of waiting period. During the waiting period, the key state of KMS key is Pending Deletion or Pending Replica Deletion , which prevents the KMS key from being used in cryptographic operations. When the waiting period expires, AWS KMS permanently deletes the KMS key. AWS KMS will not delete a multi-Region primary key that has replica keys. If you remove a multi-Region primary key from a CloudFormation stack, its key state changes to PendingReplicaDeletion so it cannot be replicated or used in cryptographic operations. This state can persist indefinitely. When the last of its replica keys is deleted, the key state of the primary key changes to PendingDeletion and the waiting period specified by PendingWindowInDays begins. When this waiting period expires, AWS KMS deletes the primary key. For details, see Deleting multi-Region keys in the AWS Key Management Service Developer Guide . You cannot use a CloudFormation template to cancel deletion of the KMS key after you remove it from the stack, regardless of the waiting period. If you specify a KMS key in your template, even one with the same name, CloudFormation creates a new KMS key. To cancel deletion of a KMS key, use the AWS KMS console or the CancelKeyDeletion operation. For information about the Pending Deletion and Pending Replica Deletion key states, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide . For more information about deleting KMS keys, see the ScheduleKeyDeletion operation in the AWS Key Management Service API Reference and Deleting KMS keys in the AWS Key Management Service Developer Guide . Minimum : 7 Maximum : 30

  • tags (Optional[Sequence[Union[CfnTag, Dict[str, Any]]]]) – Assigns one or more tags to the replica key. .. epigraph:: Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for AWS KMS in the AWS Key Management Service Developer Guide . For information about tags in AWS KMS , see Tagging keys in the AWS Key Management Service Developer Guide . For information about tags in CloudFormation, see Tag .

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_kms as kms

# key_policy: Any

cfn_key_props = kms.CfnKeyProps(
    key_policy=key_policy,

    # the properties below are optional
    description="description",
    enabled=False,
    enable_key_rotation=False,
    key_spec="keySpec",
    key_usage="keyUsage",
    multi_region=False,
    pending_window_in_days=123,
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)

Attributes

description

A description of the KMS key.

Use a description that helps you to distinguish this KMS key from others in the account, such as its intended use.

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-description

enable_key_rotation

Enables automatic rotation of the key material for the specified KMS key.

By default, automatic key rotation is not enabled.

AWS KMS supports automatic rotation only for symmetric encryption KMS keys ( KeySpec = SYMMETRIC_DEFAULT ). For asymmetric KMS keys and HMAC KMS keys, omit the EnableKeyRotation property or set it to false .

To enable automatic key rotation of the key material for a multi-Region KMS key, set EnableKeyRotation to true on the primary key (created by using AWS::KMS::Key ). AWS KMS copies the rotation status to all replica keys. For details, see Rotating multi-Region keys in the AWS Key Management Service Developer Guide .

When you enable automatic rotation, AWS KMS automatically creates new key material for the KMS key one year after the enable date and every year thereafter. AWS KMS retains all key material until you delete the KMS key. For detailed information about automatic key rotation, see Rotating KMS keys in the AWS Key Management Service Developer Guide .

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enablekeyrotation

enabled

Specifies whether the KMS key is enabled. Disabled KMS keys cannot be used in cryptographic operations.

When Enabled is true , the key state of the KMS key is Enabled . When Enabled is false , the key state of the KMS key is Disabled . The default value is true .

The actual key state of the KMS key might be affected by actions taken outside of CloudFormation, such as running the EnableKey , DisableKey , or ScheduleKeyDeletion operations.

For information about the key states of a KMS key, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide .

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enabled

key_policy

The key policy that authorizes use of the KMS key. The key policy must conform to the following rules.

  • The key policy must allow the caller to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, refer to the scenario in the Default key policy section of the AWS Key Management Service Developer Guide .

  • Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to AWS KMS . When you create a new AWS principal (for example, an IAM user or role), you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to AWS KMS . For more information, see Changes that I make are not always immediately visible in the AWS Identity and Access Management User Guide .

If you are unsure of which policy to use, consider the default key policy . This is the key policy that AWS KMS applies to KMS keys that are created by using the CreateKey API with no specified key policy. It gives the AWS account that owns the key permission to perform all operations on the key. It also allows you write IAM policies to authorize access to the key. For details, see Default key policy in the AWS Key Management Service Developer Guide .

A key policy document can include only the following characters:

  • Printable ASCII characters

  • Printable characters in the Basic Latin and Latin-1 Supplement character set

  • The tab ( \ u0009 ), line feed ( \ u000A ), and carriage return ( \ u000D ) special characters

Minimum : 1

Maximum : 32768

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy

key_spec

Specifies the type of KMS key to create.

The default value, SYMMETRIC_DEFAULT , creates a KMS key with a 256-bit symmetric key for encryption and decryption. In China Regions, SYMMETRIC_DEFAULT creates a 128-bit symmetric key that uses SM4 encryption. You can’t change the KeySpec value after the KMS key is created. For help choosing a key spec for your KMS key, see Choosing a KMS key type in the AWS Key Management Service Developer Guide .

The KeySpec property determines the type of key material in the KMS key and the algorithms that the KMS key supports. To further restrict the algorithms that can be used with the KMS key, use a condition key in its key policy or IAM policy. For more information, see AWS KMS condition keys in the AWS Key Management Service Developer Guide . .. epigraph:

If you change the value of the ``KeySpec`` property on an existing KMS key, the update request fails, regardless of the value of the ```UpdateReplacePolicy`` attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value. > `AWS services that are integrated with AWS KMS <https://docs.aws.amazon.com/kms/features/#AWS_Service_Integration>`_ use symmetric encryption KMS keys to protect your data. These services do not support encryption with asymmetric KMS keys. For help determining whether a KMS key is asymmetric, see `Identifying asymmetric KMS keys <https://docs.aws.amazon.com/kms/latest/developerguide/find-symm-asymm.html>`_ in the *AWS Key Management Service Developer Guide* .

AWS KMS supports the following key specs for KMS keys:

  • Symmetric encryption key (default)

  • SYMMETRIC_DEFAULT (AES-256-GCM)

  • HMAC keys (symmetric)

  • HMAC_224

  • HMAC_256

  • HMAC_384

  • HMAC_512

  • Asymmetric RSA key pairs

  • RSA_2048

  • RSA_3072

  • RSA_4096

  • Asymmetric NIST-recommended elliptic curve key pairs

  • ECC_NIST_P256 (secp256r1)

  • ECC_NIST_P384 (secp384r1)

  • ECC_NIST_P521 (secp521r1)

  • Other asymmetric elliptic curve key pairs

  • ECC_SECG_P256K1 (secp256k1), commonly used for cryptocurrencies.

  • SM2 key pairs (China Regions only)

  • SM2

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyspec

key_usage

//docs.aws.amazon.com/kms/latest/developerguide/concepts.html#cryptographic-operations>`_ for which you can use the KMS key. The default value is ENCRYPT_DECRYPT . This property is required for asymmetric KMS keys and HMAC KMS keys. You can’t change the KeyUsage value after the KMS key is created.

If you change the value of the KeyUsage property on an existing KMS key, the update request fails, regardless of the value of the `UpdateReplacePolicy attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value.

Select only one valid value.

  • For symmetric encryption KMS keys, omit the property or specify ENCRYPT_DECRYPT .

  • For asymmetric KMS keys with RSA key material, specify ENCRYPT_DECRYPT or SIGN_VERIFY .

  • For asymmetric KMS keys with ECC key material, specify SIGN_VERIFY .

  • For asymmetric KMS keys with SM2 (China Regions only) key material, specify ENCRYPT_DECRYPT or SIGN_VERIFY .

  • For HMAC KMS keys, specify GENERATE_VERIFY_MAC .

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyusage

Type:

Determines the `cryptographic operations <https

multi_region

Creates a multi-Region primary key that you can replicate in other AWS Regions .

You can’t change the MultiRegion value after the KMS key is created.

For a list of AWS Regions in which multi-Region keys are supported, see Multi-Region keys in AWS KMS in the ** . .. epigraph:

If you change the value of the ``MultiRegion`` property on an existing KMS key, the update request fails, regardless of the value of the ```UpdateReplacePolicy`` attribute <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html>`_ . This prevents you from accidentally deleting a KMS key by changing an immutable property value.

For a multi-Region key, set to this property to true . For a single-Region key, omit this property or set it to false . The default value is false .

Multi-Region keys are an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions . Because these KMS keys have the same key ID, key material, and other metadata, you can use them to encrypt data in one AWS Region and decrypt it in a different AWS Region without making a cross-Region call or exposing the plaintext data. For more information, see Multi-Region keys in the AWS Key Management Service Developer Guide .

You can create a symmetric encryption, HMAC, or asymmetric multi-Region KMS key, and you can create a multi-Region key with imported key material. However, you cannot create a multi-Region key in a custom key store.

To create a replica of this primary key in a different AWS Region , create an AWS::KMS::ReplicaKey resource in a CloudFormation stack in the replica Region. Specify the key ARN of this primary key.

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-multiregion

pending_window_in_days

Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack.

Enter a value between 7 and 30 days. The default value is 30 days.

When you remove a KMS key from a CloudFormation stack, AWS KMS schedules the KMS key for deletion and starts the mandatory waiting period. The PendingWindowInDays property determines the length of waiting period. During the waiting period, the key state of KMS key is Pending Deletion or Pending Replica Deletion , which prevents the KMS key from being used in cryptographic operations. When the waiting period expires, AWS KMS permanently deletes the KMS key.

AWS KMS will not delete a multi-Region primary key that has replica keys. If you remove a multi-Region primary key from a CloudFormation stack, its key state changes to PendingReplicaDeletion so it cannot be replicated or used in cryptographic operations. This state can persist indefinitely. When the last of its replica keys is deleted, the key state of the primary key changes to PendingDeletion and the waiting period specified by PendingWindowInDays begins. When this waiting period expires, AWS KMS deletes the primary key. For details, see Deleting multi-Region keys in the AWS Key Management Service Developer Guide .

You cannot use a CloudFormation template to cancel deletion of the KMS key after you remove it from the stack, regardless of the waiting period. If you specify a KMS key in your template, even one with the same name, CloudFormation creates a new KMS key. To cancel deletion of a KMS key, use the AWS KMS console or the CancelKeyDeletion operation.

For information about the Pending Deletion and Pending Replica Deletion key states, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide . For more information about deleting KMS keys, see the ScheduleKeyDeletion operation in the AWS Key Management Service API Reference and Deleting KMS keys in the AWS Key Management Service Developer Guide .

Minimum : 7

Maximum : 30

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-pendingwindowindays

tags

Assigns one or more tags to the replica key.

Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for AWS KMS in the AWS Key Management Service Developer Guide .

For information about tags in AWS KMS , see Tagging keys in the AWS Key Management Service Developer Guide . For information about tags in CloudFormation, see Tag .

Link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-tags