Skip to content

Key

This class encapsulates and extends the ROS resource type ALIYUN::KMS::Key.

Initializers

import com.aliyun.ros.cdk.kms.Key;
Key.Builder.create(Construct scope, java.lang.String id, java.lang.Boolean enableResourcePropertyConstraint)
//  .deletionProtection(java.lang.Boolean)
//  .deletionProtection(IResolvable)
//  .description(java.lang.String)
//  .description(IResolvable)
//  .dkmsInstanceId(java.lang.String)
//  .dkmsInstanceId(IResolvable)
//  .enable(java.lang.Boolean)
//  .enable(IResolvable)
//  .enableAutomaticRotation(java.lang.Boolean)
//  .enableAutomaticRotation(IResolvable)
//  .keySpec(java.lang.String)
//  .keySpec(IResolvable)
//  .keyUsage(java.lang.String)
//  .keyUsage(IResolvable)
//  .pendingWindowInDays(java.lang.Number)
//  .pendingWindowInDays(IResolvable)
//  .policy(IResolvable)
//  .policy(java.util.Map<java.lang.String, java.lang.Object>)
//  .protectionLevel(java.lang.String)
//  .protectionLevel(IResolvable)
//  .rotationInterval(java.lang.String)
//  .rotationInterval(IResolvable)
//  .tags(java.util.List<TagsProperty>)
    .build();
Name Type Description
scope com.aliyun.ros.cdk.core.Construct No description.
id java.lang.String No description.
enableResourcePropertyConstraint java.lang.Boolean No description.
deletionProtection java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable Property deletionProtection: Specifies whether to enable the release protection feature for the key.
description java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property description: The description of the CMK.
dkmsInstanceId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property dkmsInstanceId: The ID of the KMS instance.
enable java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable Property enable: Specifies whether the key is enabled.
enableAutomaticRotation java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable Property enableAutomaticRotation: Whether to enable automatic key rotation.
keySpec java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property keySpec: Key type.
keyUsage java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property keyUsage: The usage of the CMK.
pendingWindowInDays java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property pendingWindowInDays: The waiting period, specified in number of days.
policy com.aliyun.ros.cdk.core.IResolvable OR java.util.Map Property policy: The policy of key.
protectionLevel java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property protectionLevel: You do not need to specify this parameter.
rotationInterval java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property rotationInterval: The automatic rotation period.
tags java.util.List<TagsProperty> Property tags: Tags to attach to key.

scopeRequired

  • Type: com.aliyun.ros.cdk.core.Construct

idRequired

  • Type: java.lang.String

enableResourcePropertyConstraintOptional

  • Type: java.lang.Boolean

deletionProtectionOptional

  • Type: java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable

Property deletionProtection: Specifies whether to enable the release protection feature for the key.

Default is false.


descriptionOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property description: The description of the CMK.

Length constraints: Minimum length of 0 characters. Maximum length of 8192 characters.


dkmsInstanceIdOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property dkmsInstanceId: The ID of the KMS instance.

This parameter is required when you create a key for a KMS instance. This parameter is not required when you create a default key (master key).


enableOptional

  • Type: java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable

Property enable: Specifies whether the key is enabled.

Defaults to true.


enableAutomaticRotationOptional

  • Type: java.lang.Boolean OR com.aliyun.ros.cdk.core.IResolvable

Property enableAutomaticRotation: Whether to enable automatic key rotation.

Valid value: true/false (default)


keySpecOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property keySpec: Key type.

Valid value: Aliyun_AES_256/Aliyun_SM4/RSA_2048/EC_P256/EC_P256K/EC_SM2


keyUsageOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property keyUsage: The usage of the CMK.

Valid values: ENCRYPT/DECRYPT: encrypts or decrypts data. SIGN/VERIFY: generates or verifies a digital signature. If the CMK supports signature verification, the default value is SIGN/VERIFY. If the CMK does not support signature verification, the default value is ENCRYPT/DECRYPT.


pendingWindowInDaysOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property pendingWindowInDays: The waiting period, specified in number of days.

During this period, you can cancel the CMK in PendingDeletion status. After the waiting period expires, you cannot cancel the deletion. The value must be between 7 and 366. Default value is 30.


policyOptional

  • Type: com.aliyun.ros.cdk.core.IResolvable OR java.util.Map

Property policy: The policy of key.


protectionLevelOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property protectionLevel: You do not need to specify this parameter.

KMS automatically sets an appropriate protection level for your key. The protection level of the key. Valid values:

  • SOFTWARE
  • HSM
  • If you specify DKMSInstanceId, this parameter is ignored. If the instance is a software key management instance, the protection level is SOFTWARE. If the instance is a hardware key management instance, the protection level is HSM.
  • If you do not specify DKMSInstanceId, leave this parameter empty. KMS sets the protection level. If a managed HSM is available in the region, KMS sets this parameter to HSM. Otherwise, KMS sets this parameter to SOFTWARE. For more information, see Managed HSM overview.

rotationIntervalOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property rotationInterval: The automatic rotation period.

The format is integer[unit]. integer indicates the length of the period. unit indicates the unit of time. Valid units: d (day), h (hour), m (minute), and s (second). For example, both 7d and 604800s represent a period of 7 days.

  • If the key is a default key, the value is 365d.
  • If the key is a software-protected key, the value can be from 7d to 365d.
  • If the key is a hardware-protected key, automatic rotation is not supported.

This parameter is required if you set EnableAutomaticRotation to true.


tagsOptional

Property tags: Tags to attach to key.

Max support 20 tags to add during create key. Each tag with two properties Key and Value, and Key is required.


Methods

Name Description
toString Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
addCondition No description.
addCount No description.
addDependency No description.
addResourceDesc No description.
applyRemovalPolicy No description.
fetchCondition No description.
fetchDependency No description.
fetchResourceDesc No description.
getAtt No description.
setMetadata No description.

toString

public java.lang.String toString()

Returns a string representation of this construct.

synthesize

public void synthesize(ISynthesisSession session)

Allows this construct to emit artifacts into the cloud assembly during synthesis.

This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.

sessionRequired

  • Type: com.aliyun.ros.cdk.core.ISynthesisSession

The synthesis session.


addCondition

public void addCondition(RosCondition condition)

conditionRequired

  • Type: com.aliyun.ros.cdk.core.RosCondition

addCount

public void addCount(java.lang.Number OR IResolvable count)

countRequired

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

addDependency

public void addDependency(Resource resource)

resourceRequired

  • Type: com.aliyun.ros.cdk.core.Resource

addResourceDesc

public void addResourceDesc(java.lang.String desc)

descRequired

  • Type: java.lang.String

applyRemovalPolicy

public void applyRemovalPolicy(RemovalPolicy policy)

policyRequired

  • Type: com.aliyun.ros.cdk.core.RemovalPolicy

fetchCondition

public RosCondition fetchCondition()

fetchDependency

public java.util.List<java.lang.String> fetchDependency()

fetchResourceDesc

public java.lang.String fetchResourceDesc()

getAtt

public IResolvable getAtt(java.lang.String name)

nameRequired

  • Type: java.lang.String

setMetadata

public void setMetadata(java.lang.String key, java.lang.Object value)

keyRequired

  • Type: java.lang.String

valueRequired

  • Type: java.lang.Object

Static Functions

Name Description
isConstruct Return whether the given object is a Construct.

isConstruct

import com.aliyun.ros.cdk.kms.Key;
Key.isConstruct(java.lang.Object x)

Return whether the given object is a Construct.

xRequired

  • Type: java.lang.Object

Properties

Name Type Description
node com.aliyun.ros.cdk.core.ConstructNode The construct tree node associated with this construct.
env com.aliyun.ros.cdk.core.IResourceEnvironment The environment this resource belongs to.
ref java.lang.String No description.
stack com.aliyun.ros.cdk.core.Stack The stack in which this resource is defined.
resource com.aliyun.ros.cdk.core.RosResource No description.
attrKeyId java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Attribute KeyId: The globally unique identifier for the CMK.
props KeyProps No description.

nodeRequired

public ConstructNode getNode();
  • Type: com.aliyun.ros.cdk.core.ConstructNode

The construct tree node associated with this construct.


envRequired

public IResourceEnvironment getEnv();
  • Type: com.aliyun.ros.cdk.core.IResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


refRequired

public java.lang.String getRef();
  • Type: java.lang.String

stackRequired

public Stack getStack();
  • Type: com.aliyun.ros.cdk.core.Stack

The stack in which this resource is defined.


resourceOptional

public RosResource getResource();
  • Type: com.aliyun.ros.cdk.core.RosResource

attrKeyIdRequired

public java.lang.Object getAttrKeyId();
  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Attribute KeyId: The globally unique identifier for the CMK.


propsRequired

public KeyProps getProps();