Class CfnKey
- All Implemented Interfaces:
IInspectable
,ITaggable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
AWS::KMS::Key
resource specifies an KMS key in AWS Key Management Service . You can use this resource to create symmetric encryption KMS keys, asymmetric KMS keys for encryption or signing, and symmetric HMAC KMS keys. You can use AWS::KMS::Key
to create multi-Region primary keys of all supported types. To replicate a multi-Region key, use the AWS::KMS::ReplicaKey
resource.
If you change the value of the
KeySpec
,KeyUsage
,Origin
, orMultiRegion
properties of an existing KMS key, the update request fails, regardless of the value of theUpdateReplacePolicy
attribute . This prevents you from accidentally deleting a KMS key by changing any of its immutable property values. > AWS KMS replaced the term customer master key (CMK) with AWS KMS key and KMS key . The concept has not changed. To prevent breaking changes, AWS KMS is keeping some variations of this term.
You can use symmetric encryption KMS keys to encrypt and decrypt small amounts of data, but they are more commonly used to generate data keys and data key pairs. You can also use a symmetric encryption KMS key to encrypt data stored in AWS services that are integrated with AWS KMS . For more information, see Symmetric encryption KMS keys in the AWS Key Management Service Developer Guide .
You can use asymmetric KMS keys to encrypt and decrypt data or sign messages and verify signatures. To create an asymmetric key, you must specify an asymmetric KeySpec
value and a KeyUsage
value. For details, see Asymmetric keys in AWS KMS in the AWS Key Management Service Developer Guide .
You can use HMAC KMS keys (which are also symmetric keys) to generate and verify hash-based message authentication codes. To create an HMAC key, you must specify an HMAC KeySpec
value and a KeyUsage
value of GENERATE_VERIFY_MAC
. For details, see HMAC keys in AWS KMS in the AWS Key Management Service Developer Guide .
You can also create symmetric encryption, asymmetric, and HMAC multi-Region primary keys. To create a multi-Region primary key, set the MultiRegion
property to true
. For information about multi-Region keys, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide .
You cannot use the AWS::KMS::Key
resource to specify a KMS key with imported key material or a KMS key in a custom key store .
Regions
AWS KMS CloudFormation resources are available in all Regions in which AWS KMS and AWS CloudFormation are supported. You can use the AWS::KMS::Key
resource to create and manage all KMS key types that are supported in a Region.
Example:
import software.amazon.awscdk.services.kms.*; Key kmsKey = new Key(this, "myKMSKey"); Bucket myBucket = Bucket.Builder.create(this, "mySSEKMSEncryptedBucket") .encryption(BucketEncryption.KMS) .encryptionKey(kmsKey) .objectOwnership(ObjectOwnership.BUCKET_OWNER_ENFORCED) .build(); Distribution.Builder.create(this, "myDist") .defaultBehavior(BehaviorOptions.builder() .origin(S3BucketOrigin.withOriginAccessControl(myBucket)) .build()) .build(); // Add the following to scope down the key policy Map<String, Object> scopedDownKeyPolicy = Map.of( "Version", "2012-10-17", "Statement", List.of(Map.of( "Effect", "Allow", "Principal", Map.of( "AWS", "arn:aws:iam::111122223333:root"), "Action", "kms:*", "Resource", "*"), Map.of( "Effect", "Allow", "Principal", Map.of( "Service", "cloudfront.amazonaws.com"), "Action", List.of("kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*"), "Resource", "*", "Condition", Map.of( "StringEquals", Map.of( "AWS:SourceArn", "arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>"))))); CfnKey cfnKey = ((CfnKey)kmsKey.getNode().getDefaultChild()); cfnKey.getKeyPolicy() = scopedDownKeyPolicy;
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CfnKey
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnKey
(software.amazon.jsii.JsiiObjectRef objRef) CfnKey
(software.constructs.Construct scope, String id, CfnKeyProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe Amazon Resource Name (ARN) of the KMS key, such asarn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
.The key ID of the KMS key, such as1234abcd-12ab-34cd-56ef-1234567890ab
.Skips ("bypasses") the key policy lockout safety check.A description of the KMS key.Specifies whether the KMS key is enabled.Enables automatic rotation of the key material for the specified KMS key.The key policy to attach to the KMS key.Specifies the type of KMS key to create.Determines the cryptographic operations for which you can use the KMS key.Creates a multi-Region primary key that you can replicate in other AWS Regions .The source of the key material for the KMS key.Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack.Specifies a custom period of time between each rotation date.getTags()
Tag Manager which manages the tags for this resource.Assigns one or more tags to the replica key.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
Skips ("bypasses") the key policy lockout safety check.void
Skips ("bypasses") the key policy lockout safety check.void
setDescription
(String value) A description of the KMS key.void
setEnabled
(Boolean value) Specifies whether the KMS key is enabled.void
setEnabled
(IResolvable value) Specifies whether the KMS key is enabled.void
setEnableKeyRotation
(Boolean value) Enables automatic rotation of the key material for the specified KMS key.void
setEnableKeyRotation
(IResolvable value) Enables automatic rotation of the key material for the specified KMS key.void
setKeyPolicy
(Object value) The key policy to attach to the KMS key.void
setKeySpec
(String value) Specifies the type of KMS key to create.void
setKeyUsage
(String value) Determines the cryptographic operations for which you can use the KMS key.void
setMultiRegion
(Boolean value) Creates a multi-Region primary key that you can replicate in other AWS Regions .void
setMultiRegion
(IResolvable value) Creates a multi-Region primary key that you can replicate in other AWS Regions .void
The source of the key material for the KMS key.void
setPendingWindowInDays
(Number value) Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack.void
setRotationPeriodInDays
(Number value) Specifies a custom period of time between each rotation date.void
setTagsRaw
(List<CfnTag> value) Assigns one or more tags to the replica key.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnKey
protected CfnKey(software.amazon.jsii.JsiiObjectRef objRef) -
CfnKey
protected CfnKey(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnKey
@Stability(Stable) public CfnKey(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnKeyProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties.
-
CfnKey
- Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrArn
The Amazon Resource Name (ARN) of the KMS key, such asarn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
.For information about the key ARN of a KMS key, see Key ARN in the AWS Key Management Service Developer Guide .
-
getAttrKeyId
The key ID of the KMS key, such as1234abcd-12ab-34cd-56ef-1234567890ab
.For information about the key ID of a KMS key, see Key ID in the AWS Key Management Service Developer Guide .
-
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getTags
Tag Manager which manages the tags for this resource. -
getBypassPolicyLockoutSafetyCheck
Skips ("bypasses") the key policy lockout safety check.The default value is false.
-
setBypassPolicyLockoutSafetyCheck
Skips ("bypasses") the key policy lockout safety check.The default value is false.
-
setBypassPolicyLockoutSafetyCheck
Skips ("bypasses") the key policy lockout safety check.The default value is false.
-
getDescription
A description of the KMS key. -
setDescription
A description of the KMS key. -
getEnabled
Specifies whether the KMS key is enabled.Disabled KMS keys cannot be used in cryptographic operations.
-
setEnabled
Specifies whether the KMS key is enabled.Disabled KMS keys cannot be used in cryptographic operations.
-
setEnabled
Specifies whether the KMS key is enabled.Disabled KMS keys cannot be used in cryptographic operations.
-
getEnableKeyRotation
Enables automatic rotation of the key material for the specified KMS key. -
setEnableKeyRotation
Enables automatic rotation of the key material for the specified KMS key. -
setEnableKeyRotation
Enables automatic rotation of the key material for the specified KMS key. -
getKeyPolicy
The key policy to attach to the KMS key. -
setKeyPolicy
The key policy to attach to the KMS key. -
getKeySpec
Specifies the type of KMS key to create. -
setKeySpec
Specifies the type of KMS key to create. -
getKeyUsage
Determines the cryptographic operations for which you can use the KMS key. The default value isENCRYPT_DECRYPT
. This property is required for asymmetric KMS keys and HMAC KMS keys. You can't change theKeyUsage
value after the KMS key is created. -
setKeyUsage
Determines the cryptographic operations for which you can use the KMS key. The default value isENCRYPT_DECRYPT
. This property is required for asymmetric KMS keys and HMAC KMS keys. You can't change theKeyUsage
value after the KMS key is created. -
getMultiRegion
Creates a multi-Region primary key that you can replicate in other AWS Regions . -
setMultiRegion
Creates a multi-Region primary key that you can replicate in other AWS Regions . -
setMultiRegion
Creates a multi-Region primary key that you can replicate in other AWS Regions . -
getOrigin
The source of the key material for the KMS key. -
setOrigin
The source of the key material for the KMS key. -
getPendingWindowInDays
Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack. -
setPendingWindowInDays
Specifies the number of days in the waiting period before AWS KMS deletes a KMS key that has been removed from a CloudFormation stack. -
getRotationPeriodInDays
Specifies a custom period of time between each rotation date. -
setRotationPeriodInDays
Specifies a custom period of time between each rotation date. -
getTagsRaw
Assigns one or more tags to the replica key. -
setTagsRaw
Assigns one or more tags to the replica key.
-