KeyProps
- class aws_cdk.aws_kms.KeyProps(*, admins=None, alias=None, description=None, enabled=None, enable_key_rotation=None, key_spec=None, key_usage=None, pending_window=None, policy=None, removal_policy=None, trust_account_identities=None)
Bases:
object
Construction properties for a KMS Key object.
- Parameters:
admins (
Optional
[Sequence
[IPrincipal
]]) – A list of principals to add as key administrators to the key policy. Key administrators have permissions to manage the key (e.g., change permissions, revoke), but do not have permissions to use the key in cryptographic operations (e.g., encrypt, decrypt). These principals will be added to the default key policy (if none specified), or to the specified policy (if provided). Default: []alias (
Optional
[str
]) – Initial alias to add to the key. More aliases can be added later by callingaddAlias
. Default: - No alias is added for the key.description (
Optional
[str
]) – A description of the key. Use a description that helps your users decide whether the key is appropriate for a particular task. Default: - No description.enabled (
Optional
[bool
]) – Indicates whether the key is available for use. Default: - Key is enabled.enable_key_rotation (
Optional
[bool
]) – Indicates whether AWS KMS rotates the key. Default: falsekey_spec (
Optional
[KeySpec
]) – The cryptographic configuration of the key. The valid value depends on usage of the key. IMPORTANT: If you change this property of an existing key, the existing key is scheduled for deletion and a new key is created with the specified value. Default: KeySpec.SYMMETRIC_DEFAULTkey_usage (
Optional
[KeyUsage
]) – The cryptographic operations for which the key can be used. IMPORTANT: If you change this property of an existing key, the existing key is scheduled for deletion and a new key is created with the specified value. Default: KeyUsage.ENCRYPT_DECRYPTpending_window (
Optional
[Duration
]) – Specifies the number of days in the waiting period before AWS KMS deletes a CMK that has been removed from a CloudFormation stack. When you remove a customer master key (CMK) from a CloudFormation stack, AWS KMS schedules the CMK 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 CMK is Pending Deletion, which prevents the CMK from being used in cryptographic operations. When the waiting period expires, AWS KMS permanently deletes the CMK. Enter a value between 7 and 30 days. Default: - 30 dayspolicy (
Optional
[PolicyDocument
]) – Custom policy document to attach to the KMS key. NOTE - If the@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set (the default for new projects), this policy will override the default key policy and become the only key policy for the key. If the feature flag is not set, this policy will be appended to the default key policy. Default: - A policy document with permissions for the account root to administer the key will be created.removal_policy (
Optional
[RemovalPolicy
]) – Whether the encryption key should be retained when it is removed from the Stack. This is useful when one wants to retain access to data that was encrypted with a key that is being retired. Default: RemovalPolicy.Retaintrust_account_identities (
Optional
[bool
]) – (deprecated) Whether the key usage can be granted by IAM policies. Setting this to true adds a default statement which delegates key access control completely to the identity’s IAM policy (similar to how it works for other AWS resources). This matches the default behavior when creating KMS keys via the API or console. If the@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set (the default for new projects), this flag will always be treated as ‘true’ and does not need to be explicitly set. Default: - false, unless the@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set.
- ExampleMetadata:
infused
Example:
my_trusted_admin_role = iam.Role.from_role_arn(self, "TrustedRole", "arn:aws:iam:....") # Creates a limited admin policy and assigns to the account root. my_custom_policy = iam.PolicyDocument( statements=[iam.PolicyStatement( actions=["kms:Create*", "kms:Describe*", "kms:Enable*", "kms:List*", "kms:Put*" ], principals=[iam.AccountRootPrincipal()], resources=["*"] )] ) key = kms.Key(self, "MyKey", policy=my_custom_policy )
Attributes
- admins
A list of principals to add as key administrators to the key policy.
Key administrators have permissions to manage the key (e.g., change permissions, revoke), but do not have permissions to use the key in cryptographic operations (e.g., encrypt, decrypt).
These principals will be added to the default key policy (if none specified), or to the specified policy (if provided).
- Default:
[]
- alias
Initial alias to add to the key.
More aliases can be added later by calling
addAlias
.- Default:
No alias is added for the key.
- description
A description of the key.
Use a description that helps your users decide whether the key is appropriate for a particular task.
- Default:
No description.
- enable_key_rotation
Indicates whether AWS KMS rotates the key.
- Default:
false
- enabled
Indicates whether the key is available for use.
- Default:
Key is enabled.
- key_spec
The cryptographic configuration of the key. The valid value depends on usage of the key.
IMPORTANT: If you change this property of an existing key, the existing key is scheduled for deletion and a new key is created with the specified value.
- Default:
KeySpec.SYMMETRIC_DEFAULT
- key_usage
The cryptographic operations for which the key can be used.
IMPORTANT: If you change this property of an existing key, the existing key is scheduled for deletion and a new key is created with the specified value.
- Default:
KeyUsage.ENCRYPT_DECRYPT
- pending_window
Specifies the number of days in the waiting period before AWS KMS deletes a CMK that has been removed from a CloudFormation stack.
When you remove a customer master key (CMK) from a CloudFormation stack, AWS KMS schedules the CMK 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 CMK is Pending Deletion, which prevents the CMK from being used in cryptographic operations. When the waiting period expires, AWS KMS permanently deletes the CMK.
Enter a value between 7 and 30 days.
- policy
Custom policy document to attach to the KMS key.
NOTE - If the
@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set (the default for new projects), this policy will override the default key policy and become the only key policy for the key. If the feature flag is not set, this policy will be appended to the default key policy.- Default:
A policy document with permissions for the account root to
administer the key will be created.
- removal_policy
Whether the encryption key should be retained when it is removed from the Stack.
This is useful when one wants to retain access to data that was encrypted with a key that is being retired.
- Default:
RemovalPolicy.Retain
- trust_account_identities
(deprecated) Whether the key usage can be granted by IAM policies.
Setting this to true adds a default statement which delegates key access control completely to the identity’s IAM policy (similar to how it works for other AWS resources). This matches the default behavior when creating KMS keys via the API or console.
If the
@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set (the default for new projects), this flag will always be treated as ‘true’ and does not need to be explicitly set.- Default:
false, unless the
@aws-cdk/aws-kms:defaultKeyPolicies
feature flag is set.
- Deprecated:
redundant with the
@aws-cdk/aws-kms:defaultKeyPolicies
feature flag- See:
- Stability:
deprecated