Mixin
- class aws_cdk.Mixin
Bases:
objectAbstract base class for mixins that provides default implementations.
- ExampleMetadata:
fixture=README-mixins infused
Example:
class MyEncryptionAtRest(Mixin): def __init__(self, *, bucketKey=None, algorithm=None): super().__init__() # Validate Mixin props at construction time if bucket_key && algorithm == "aws:kms:dsse": throw new Error("Cannot use S3 Bucket Key and DSSE together"); def supports(self, construct): return s3.CfnBucket.is_cfn_bucket(construct) def apply_to(self, target): # Validate pre-conditions on the target, throw if error is unrecoverable if not target.bucket_encryption: throw new Error("Bucket encryption not configured"); # Validate properties are met after app execution target.node.add_validation({ "validate": () => isKmsEncrypted(target) ? ['This bucket must use aws:kms encryption.'] : [] }) target.bucket_encryption = s3.CfnBucket.BucketEncryptionProperty( server_side_encryption_configuration=[s3.CfnBucket.ServerSideEncryptionRuleProperty( bucket_key_enabled=True, server_side_encryption_by_default=s3.CfnBucket.ServerSideEncryptionByDefaultProperty( sse_algorithm="aws:kms" ) )] ) return targetMethods
- abstractmethod apply_to(construct)
Applies the mixin functionality to the target construct.
- Parameters:
construct (
IConstruct)- Return type:
None
- supports(_construct)
Determines whether this mixin can be applied to the given construct.
- Parameters:
_construct (
IConstruct)- Return type:
bool
Static Methods
- classmethod is_mixin(x)
Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.