interface KeyProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.KMS.KeyProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awskms#KeyProps |
Java | software.amazon.awscdk.services.kms.KeyProps |
Python | aws_cdk.aws_kms.KeyProps |
TypeScript (source) | aws-cdk-lib » aws_kms » KeyProps |
Construction properties for a KMS Key object.
Example
import * as kms from 'aws-cdk-lib/aws-kms';
const sourceOutput = new codepipeline.Artifact();
const targetBucket = new s3.Bucket(this, 'MyBucket');
const key: kms.IKey = new kms.Key(this, 'EnvVarEncryptKey', {
description: 'sample key',
});
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const deployAction = new codepipeline_actions.S3DeployAction({
actionName: 'S3Deploy',
bucket: targetBucket,
input: sourceOutput,
encryptionKey: key,
});
const deployStage = pipeline.addStage({
stageName: 'Deploy',
actions: [deployAction],
});
Properties
Name | Type | Description |
---|---|---|
admins? | IPrincipal [] | A list of principals to add as key administrators to the key policy. |
alias? | string | Initial alias to add to the key. |
description? | string | A description of the key. |
enable | boolean | Indicates whether AWS KMS rotates the key. |
enabled? | boolean | Indicates whether the key is available for use. |
key | Key | The cryptographic configuration of the key. The valid value depends on usage of the key. |
key | Key | The cryptographic operations for which the key can be used. |
multi | boolean | Creates a multi-Region primary key that you can replicate in other AWS Regions. |
pending | Duration | Specifies the number of days in the waiting period before AWS KMS deletes a CMK that has been removed from a CloudFormation stack. |
policy? | Policy | Custom policy document to attach to the KMS key. |
removal | Removal | Whether the encryption key should be retained when it is removed from the Stack. |
rotation | Duration | The period between each automatic rotation. |
admins?
Type:
IPrincipal
[]
(optional, default: [])
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).
alias?
Type:
string
(optional, default: No alias is added for the key.)
Initial alias to add to the key.
More aliases can be added later by calling addAlias
.
description?
Type:
string
(optional, default: No description.)
A description of the key.
Use a description that helps your users decide whether the key is appropriate for a particular task.
enableKeyRotation?
Type:
boolean
(optional, default: false)
Indicates whether AWS KMS rotates the key.
enabled?
Type:
boolean
(optional, default: Key is enabled.)
Indicates whether the key is available for use.
keySpec?
Type:
Key
(optional, default: KeySpec.SYMMETRIC_DEFAULT)
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.
keyUsage?
Type:
Key
(optional, default: KeyUsage.ENCRYPT_DECRYPT)
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.
multiRegion?
Type:
boolean
(optional, default: false)
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.
IMPORTANT: 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.
This prevents you from accidentally deleting a KMS key by changing an immutable property value.
See also: https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html
pendingWindow?
Type:
Duration
(optional, default: 30 days)
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?
Type:
Policy
(optional, default: A policy document with permissions for the account root to
administer the key will be created.)
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.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.Retain)
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.
rotationPeriod?
Type:
Duration
(optional, default: set by CFN to 365 days.)
The period between each automatic rotation.