CfnKey L1 construct
The 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, orMultiRegionproperties of an existing KMS key, the update request fails, regardless of the value of theUpdateReplacePolicyattribute . This prevents you from accidentally deleting a KMS key by changing any of its immutable property values. > AWS replaced the term customer master key (CMK) with AWS KMS key and KMS key . The concept has not changed. To prevent breaking changes, AWS 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 . 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 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 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 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 CloudFormation resources are available in all Regions in which AWS and 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 * as kms from 'aws-cdk-lib/aws-kms';
const kmsKey = new kms.Key(this, 'myKMSKey');
const myBucket = new s3.Bucket(this, 'mySSEKMSEncryptedBucket', {
encryption: s3.BucketEncryption.KMS,
encryptionKey: kmsKey,
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,
});
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: {
origin: origins.S3BucketOrigin.withOriginAccessControl(myBucket)
},
});
// Add the following to scope down the key policy
const scopedDownKeyPolicy = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:root"
},
"Action": "kms:*",
"Resource": "*"
},
{
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:GenerateDataKey*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>"
}
}
}
]
};
const cfnKey = (kmsKey.node.defaultChild as kms.CfnKey);
cfnKey.keyPolicy = scopedDownKeyPolicy;
import aws_cdk.aws_kms as kms
kms_key = kms.Key(self, "myKMSKey")
my_bucket = s3.Bucket(self, "mySSEKMSEncryptedBucket",
encryption=s3.BucketEncryption.KMS,
encryption_key=kms_key,
object_ownership=s3.ObjectOwnership.BUCKET_OWNER_ENFORCED
)
cloudfront.Distribution(self, "myDist",
default_behavior=cloudfront.BehaviorOptions(
origin=origins.S3BucketOrigin.with_origin_access_control(my_bucket)
)
)
# Add the following to scope down the key policy
scoped_down_key_policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:root"
},
"Action": "kms:*",
"Resource": "*"
}, {
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>"
}
}
}
]
}
cfn_key = (kms_key.node.default_child)
cfn_key.key_policy = scoped_down_key_policy
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;
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.KMS;
var kmsKey = new Key(this, "myKMSKey");
var myBucket = new Bucket(this, "mySSEKMSEncryptedBucket", new BucketProps {
Encryption = BucketEncryption.KMS,
EncryptionKey = kmsKey,
ObjectOwnership = ObjectOwnership.BUCKET_OWNER_ENFORCED
});
new Distribution(this, "myDist", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = S3BucketOrigin.WithOriginAccessControl(myBucket)
}
});
// Add the following to scope down the key policy
IDictionary<string, object> scopedDownKeyPolicy = new Dictionary<string, object> {
{ "Version", "2012-10-17" },
{ "Statement", new [] { new Dictionary<string, object> {
{ "Effect", "Allow" },
{ "Principal", new Dictionary<string, string> {
{ "AWS", "arn:aws:iam::111122223333:root" }
} },
{ "Action", "kms:*" },
{ "Resource", "*" }
}, new Dictionary<string, object> {
{ "Effect", "Allow" },
{ "Principal", new Dictionary<string, string> {
{ "Service", "cloudfront.amazonaws.com" }
} },
{ "Action", new [] { "kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*" } },
{ "Resource", "*" },
{ "Condition", new Dictionary<string, IDictionary<string, string>> {
{ "StringEquals", new Dictionary<string, string> {
{ "AWS:SourceArn", "arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>" }
} }
} }
} } }
};
var cfnKey = ((CfnKey)kmsKey.Node.DefaultChild);
cfnKey.KeyPolicy = scopedDownKeyPolicy;
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import kms "github.com/aws/aws-cdk-go/awscdk"
kmsKey := kms.NewKey(this, jsii.String("myKMSKey"))
myBucket := s3.NewBucket(this, jsii.String("mySSEKMSEncryptedBucket"), &BucketProps{
Encryption: s3.BucketEncryption_KMS,
EncryptionKey: kmsKey,
ObjectOwnership: s3.ObjectOwnership_BUCKET_OWNER_ENFORCED,
})
cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
DefaultBehavior: &BehaviorOptions{
Origin: origins.S3BucketOrigin_WithOriginAccessControl(myBucket),
},
})
// Add the following to scope down the key policy
scopedDownKeyPolicy := map[string]interface{}{
"Version": jsii.String("2012-10-17"),
"Statement": []interface{}{
map[string]interface{}{
"Effect": jsii.String("Allow"),
"Principal": map[string]*string{
"AWS": jsii.String("arn:aws:iam::111122223333:root"),
},
"Action": jsii.String("kms:*"),
"Resource": jsii.String("*"),
},
map[string]interface{}{
"Effect": jsii.String("Allow"),
"Principal": map[string]*string{
"Service": jsii.String("cloudfront.amazonaws.com"),
},
"Action": []*string{
jsii.String("kms:Decrypt"),
jsii.String("kms:Encrypt"),
jsii.String("kms:GenerateDataKey*"),
},
"Resource": jsii.String("*"),
"Condition": map[string]map[string]*string{
"StringEquals": map[string]*string{
"AWS:SourceArn": jsii.String("arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>"),
},
},
},
},
}
cfnKey := (kmsKey.Node.defaultChild.(CfnKey))
cfnKey.keyPolicy = scopedDownKeyPolicy
Initializer
new CfnKey(scope: Construct, id: string, props?: CfnKeyProps)
CfnKey(scope: Construct, id: str, props: typing.Optional[CfnKeyProps] = None)
new CfnKey(Construct scope, String id, CfnKeyProps props)
new CfnKey(Construct scope, string id, CfnKeyProps? props = null)
NewCfnKey(Scope Construct, Id *string, Props CfnKeyProps)
Construct Props
bypassPolicyLockoutSafetyCheckoptionalboolean | IResolvablebypass_policy_lockout_safety_checkoptionaltyping.Union[bool, IResolvable]bypassPolicyLockoutSafetyCheckoptionalBooleanBypassPolicyLockoutSafetyCheckoptionalboolBypassPolicyLockoutSafetyCheckoptionalinterface{}= false#notes
Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
For more information, see Default key policy in the AWS Key Management Service Developer Guide .
Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#Use a description that helps you to distinguish this KMS key from others in the account, such as its intended use.
enabledoptionalboolean | IResolvableenabledoptionaltyping.Union[bool, IResolvable]enabledoptionalBooleanEnabledoptionalboolEnabledoptionalinterface{}#notes
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 .
enableKeyRotationoptionalboolean | IResolvableenable_key_rotationoptionaltyping.Union[bool, IResolvable]enableKeyRotationoptionalBooleanEnableKeyRotationoptionalboolEnableKeyRotationoptionalinterface{}#notes
By default, automatic key rotation is not enabled.
AWS supports automatic rotation only for symmetric encryption KMS keys ( KeySpec = SYMMETRIC_DEFAULT ). For asymmetric KMS keys, HMAC KMS keys, and KMS keys with Origin EXTERNAL , 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 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 automatically creates new key material for the KMS key one year after the enable date and every year thereafter. AWS 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 .
keyPolicyoptionalanykey_policyoptionalAnykeyPolicyoptionalObjectKeyPolicyoptionalobjectKeyPolicyoptionalinterface{}#notes
If you provide a key policy, it must meet the following criteria:
- 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, see Default key policy in the AWS Key Management Service Developer Guide . (To omit this condition, set
BypassPolicyLockoutSafetyCheckto true.) - 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 . 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 . For more information, see Changes that I make are not always immediately visible in the AWS Identity and Access Management User Guide .
If you do not provide a key policy, AWS attaches a default key policy to the KMS key. For more information, 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
keySpecoptionalstringkey_specoptionalstrkeySpecoptionalStringKeySpecoptionalstringKeySpecoptional*string= "SYMMETRIC_DEFAULT"#notes
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 condition keys in the AWS Key Management Service Developer Guide .
If you change the value of the
KeySpecproperty on an existing KMS key, the update request fails, regardless of the value of theUpdateReplacePolicyattribute . This prevents you from accidentally deleting a KMS key by changing an immutable property value. > AWS services that are integrated with AWS 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 supports the following key specs for KMS keys:
Symmetric encryption key (default)
SYMMETRIC_DEFAULT(AES-256-GCM)HMAC keys (symmetric)
HMAC_224HMAC_256HMAC_384HMAC_512Asymmetric RSA key pairs (encryption and decryption or signing and verification)
RSA_2048RSA_3072RSA_4096Asymmetric NIST-recommended elliptic curve key pairs (signing and verification or deriving shared secrets)
ECC_NIST_P256(secp256r1)ECC_NIST_P384(secp384r1)ECC_NIST_P521(secp521r1)ECC_NIST_EDWARDS25519(ed25519) - signing and verification onlyNote: For ECC_NIST_EDWARDS25519 KMS keys, the ED25519_SHA_512 signing algorithm requires
MessageType:RAW, while ED25519_PH_SHA_512 requiresMessageType:DIGEST. These message types cannot be used interchangeably.Other asymmetric elliptic curve key pairs (signing and verification)
ECC_SECG_P256K1(secp256k1), commonly used for cryptocurrencies.Asymmetric ML-DSA key pairs (signing and verification)
ML_DSA_44ML_DSA_65ML_DSA_87SM2 key pairs (encryption and decryption or signing and verification or deriving shared secrets)
SM2(China Regions only)
keyUsageoptionalstringkey_usageoptionalstrkeyUsageoptionalStringKeyUsageoptionalstringKeyUsageoptional*string= "ENCRYPT_DECRYPT"#notes
If you change the value of the
KeyUsageproperty on an existing KMS key, the update request fails, regardless of the value of theUpdateReplacePolicyattribute . 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 parameter or specify
ENCRYPT_DECRYPT. - For HMAC KMS keys (symmetric), specify
GENERATE_VERIFY_MAC. - For asymmetric KMS keys with RSA key pairs, specify
ENCRYPT_DECRYPTorSIGN_VERIFY. - For asymmetric KMS keys with NIST-recommended elliptic curve key pairs, specify
SIGN_VERIFYorKEY_AGREEMENT. - For asymmetric KMS keys with
ECC_SECG_P256K1key pairs, specifySIGN_VERIFY. - For asymmetric KMS keys with ML-DSA key pairs, specify
SIGN_VERIFY. - For asymmetric KMS keys with SM2 key pairs (China Regions only), specify
ENCRYPT_DECRYPT,SIGN_VERIFY, orKEY_AGREEMENT.
multiRegionoptionalboolean | IResolvablemulti_regionoptionaltyping.Union[bool, IResolvable]multiRegionoptionalBooleanMultiRegionoptionalboolMultiRegionoptionalinterface{}= false#notes
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 in the ** .
If you change the value of the
MultiRegionproperty on an existing KMS key, the update request fails, regardless of the value of theUpdateReplacePolicyattribute . 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 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.
originoptionalstringoriginoptionalstroriginoptionalStringOriginoptionalstringOriginoptional*string= "AWS_KMS"#notes
You cannot change the origin after you create the KMS key. The default is AWS_KMS , which means that AWS creates the key material.
To create a KMS key with no key material (for imported key material), set this value to EXTERNAL . For more information about importing key material into AWS , see Importing Key Material in the AWS Key Management Service Developer Guide .
You can ignore ENABLED when Origin is EXTERNAL . When a KMS key with Origin EXTERNAL is created, the key state is PENDING_IMPORT and ENABLED is false . After you import the key material, ENABLED updated to true . The KMS key can then be used for Cryptographic Operations.
- CloudFormation doesn't support creating an
Originparameter of theAWS_CLOUDHSMorEXTERNAL_KEY_STOREvalues.EXTERNALis not supported for ML-DSA keys.
pendingWindowInDaysoptionalnumberpending_window_in_daysoptionalint | floatpendingWindowInDaysoptionalNumberPendingWindowInDaysoptionaldoublePendingWindowInDaysoptional*float64#notes
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 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 permanently deletes the KMS key.
AWS 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 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 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 .
rotationPeriodInDaysoptionalnumberrotation_period_in_daysoptionalint | floatrotationPeriodInDaysoptionalNumberRotationPeriodInDaysoptionaldoubleRotationPeriodInDaysoptional*float64= 365#notes
If no value is specified, the default value is 365 days.
The rotation period defines the number of days after you enable automatic key rotation that AWS will rotate your key material, and the number of days between each automatic rotation thereafter.
You can use the kms:RotationPeriodInDays condition key to further constrain the values that principals can specify in the RotationPeriodInDays parameter.
For more information about rotating KMS keys and automatic rotation, see Rotating keys in the AWS Key Management Service Developer Guide .
tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag#notes
Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for AWS in the AWS Key Management Service Developer Guide .
For information about tags in AWS , see Tagging keys in the AWS Key Management Service Developer Guide . For information about tags in CloudFormation, see Tag .
Properties
For information about the key ARN of a KMS key, see Key ARN in the AWS Key Management Service Developer Guide .
For information about the key ID of a KMS key, see Key ID in the AWS Key Management Service Developer Guide .
bypassPolicyLockoutSafetyCheckmay be undefinedboolean | IResolvablebypass_policy_lockout_safety_checkmay be undefinedtyping.Union[bool, IResolvable]bypassPolicyLockoutSafetyCheckmay be undefinedBooleanBypassPolicyLockoutSafetyCheckmay be undefinedboolBypassPolicyLockoutSafetyCheckmay be undefinedinterface{}#The default value is false.
CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptions#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#descriptionmay be undefinedstringdescriptionmay be undefinedstrdescriptionmay be undefinedStringDescriptionmay be undefinedstringDescriptionmay be undefined*string#enabledmay be undefinedboolean | IResolvableenabledmay be undefinedtyping.Union[bool, IResolvable]enabledmay be undefinedBooleanEnabledmay be undefinedboolEnabledmay be undefinedinterface{}#Disabled KMS keys cannot be used in cryptographic operations.
enableKeyRotationmay be undefinedboolean | IResolvableenable_key_rotationmay be undefinedtyping.Union[bool, IResolvable]enableKeyRotationmay be undefinedBooleanEnableKeyRotationmay be undefinedboolEnableKeyRotationmay be undefinedinterface{}#keySpecmay be undefinedstringkey_specmay be undefinedstrkeySpecmay be undefinedStringKeySpecmay be undefinedstringKeySpecmay be undefined*string#keyUsagemay be undefinedstringkey_usagemay be undefinedstrkeyUsagemay be undefinedStringKeyUsagemay be undefinedstringKeyUsagemay be undefined*string#The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId).
multiRegionmay be undefinedboolean | IResolvablemulti_regionmay be undefinedtyping.Union[bool, IResolvable]multiRegionmay be undefinedBooleanMultiRegionmay be undefinedboolMultiRegionmay be undefinedinterface{}#originmay be undefinedstringoriginmay be undefinedstroriginmay be undefinedStringOriginmay be undefinedstringOriginmay be undefined*string#pendingWindowInDaysmay be undefinednumberpending_window_in_daysmay be undefinedint | floatpendingWindowInDaysmay be undefinedNumberPendingWindowInDaysmay be undefineddoublePendingWindowInDaysmay be undefined*float64#If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).
rotationPeriodInDaysmay be undefinednumberrotation_period_in_daysmay be undefinedint | floatrotationPeriodInDaysmay be undefinedNumberRotationPeriodInDaysmay be undefineddoubleRotationPeriodInDaysmay be undefined*float64#CfnElements must be defined within a stack scope (directly or indirectly).
Methods
addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#1 parameter
Parameters
pathpathpathpathPath— The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.
addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.
addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#notes · 2 parameters
To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.
For example,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"Properties": {
"GlobalSecondaryIndexes": [
{
"Projection": {
"NonKeyAttributes": [ "myattribute" ]
...
}
...
},
{
"ProjectionType": "INCLUDE"
...
},
]
...
}
The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.
Parameters
pathpathpathpathPath— - The path of the property, you can use dot notation to override values in complex types.valuevaluevaluevalueValue— - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#1 parameter
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#Syntactic sugar for addOverride("Properties.<...>", value).
2 parameters
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path of the property.valuevaluevaluevalueValue— The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.
1 parameter
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:
cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#fromKeyArn(scope: Construct, id: string, arn: string): IKeyRef@staticmethod def from_key_arn(scope: Construct, id: str, arn: str) -> IKeyRefpublic static IKeyRef fromKeyArn(Construct scope, String id, String arn)public static IKeyRef FromKeyArn(Construct scope, string id, string arn)func FromKeyArn(Scope Construct, Id *string, Arn *string) IKeyRefstatic#fromKeyId(scope: Construct, id: string, keyId: string): IKeyRef@staticmethod def from_key_id(scope: Construct, id: str, key_id: str) -> IKeyRefpublic static IKeyRef fromKeyId(Construct scope, String id, String keyId)public static IKeyRef FromKeyId(Construct scope, string id, string keyId)func FromKeyId(Scope Construct, Id *string, KeyId *string) IKeyRefstatic#getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.
1 parameter
Parameters
attributeNameattribute_nameattributeNameattributeNameAttributeName— The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#1 parameter
Parameters
inspectorinspectorinspectorinspectorInspector— tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isCfnKey(x: any): boolean@staticmethod def is_cfn_key(x: Any) -> boolpublic static Boolean isCfnKey(Object x)public static bool IsCfnKey(object x)func IsCfnKey(X interface{}) *boolstatic#isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#2 parameters
Parameters
targettargettargettargetTarget— The dependency to replace.newTargetnew_targetnewTargetnewTargetNewTarget— The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#returns
Returns: a string representation of this resource
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.