AWS Security ChangesHomeSearch

AWS cdk medium security documentation change

Service: cdk · 2026-03-13 · Security-related medium

File: cdk/v2/guide/constructs.md

Summary

Added documentation about Mixins feature allowing security configurations like S3 bucket versioning, block public access, and auto-delete objects

Security assessment

The change demonstrates applying security controls (blocking public access, versioning) via Mixins. These are security best practices for S3 buckets to prevent data leaks and ensure recoverability.

Diff

diff --git a/cdk/v2/guide/constructs.md b/cdk/v2/guide/constructs.md
index 97ee4ec59..eea01324d 100644
--- a//cdk/v2/guide/constructs.md
+++ b//cdk/v2/guide/constructs.md
@@ -41 +41 @@ L2 constructs, also known as _curated_ constructs, are thoughtfully developed by
-L2 constructs also provide helper methods for most resources that make it simpler and quicker to define properties, permissions, event-based interactions between resources, and more.
+L2 constructs also provide helper methods for most resources that make it simpler and quicker to define properties, permissions, event-based interactions between resources, and more. Many of these features are also available as independent building blocks called [Mixins](./mixins.html), which can be applied to both L1 and L2 constructs using the `.with()` method.
@@ -289,0 +290,110 @@ For information about the most common API patterns in the AWS Construct Library,
+### Add features with Mixins
+
+Mixins are composable features that you can apply to any construct using the `.with()` method. Mixins let you add functionality to L1 and L2 constructs without having to use a different construct or write low-level code.
+
+For example, you can enable versioning and block public access on an Amazon S3 bucket — whether it’s an L1 `CfnBucket` or an L2 `Bucket`:
+
+###### Example
+
+TypeScript
+    
+    
+    
+    import * as cdk from 'aws-cdk-lib';
+    import * as s3 from 'aws-cdk-lib/aws-s3';
+    
+    // Apply mixins to an L1 construct
+    new s3.CfnBucket(this, 'MyBucket')
+      .with(new s3.mixins.BucketVersioning())
+      .with(new s3.mixins.BucketBlockPublicAccess());
+    
+    // Apply mixins to an L2 construct
+    new s3.Bucket(this, 'MyL2Bucket', { removalPolicy: cdk.RemovalPolicy.DESTROY })
+      .with(new s3.mixins.BucketAutoDeleteObjects());
+
+JavaScript
+    
+    
+    
+    const cdk = require('aws-cdk-lib');
+    const s3 = require('aws-cdk-lib/aws-s3');
+    
+    // Apply mixins to an L1 construct
+    new s3.CfnBucket(this, 'MyBucket')
+      .with(new s3.mixins.BucketVersioning())
+      .with(new s3.mixins.BucketBlockPublicAccess());
+    
+    // Apply mixins to an L2 construct
+    new s3.Bucket(this, 'MyL2Bucket', { removalPolicy: cdk.RemovalPolicy.DESTROY })
+      .with(new s3.mixins.BucketAutoDeleteObjects());
+
+Python
+    
+    
+    
+    import aws_cdk as cdk
+    import aws_cdk.aws_s3 as s3
+    
+    # Apply mixins to an L1 construct
+    s3.CfnBucket(self, "MyBucket") \
+        .with_(s3.mixins.BucketVersioning()) \
+        .with_(s3.mixins.BucketBlockPublicAccess())
+    
+    # Apply mixins to an L2 construct
+    s3.Bucket(self, "MyL2Bucket", removal_policy=cdk.RemovalPolicy.DESTROY) \
+        .with_(s3.mixins.BucketAutoDeleteObjects())
+
+Java
+    
+    
+    
+    import software.amazon.awscdk.*;
+    import software.amazon.awscdk.services.s3.*;
+    
+    // Apply mixins to an L1 construct
+    CfnBucket bucket = new CfnBucket(this, "MyBucket");
+    bucket.with(new BucketVersioning());
+    bucket.with(new BucketBlockPublicAccess());
+    
+    // Apply mixins to an L2 construct
+    Bucket l2Bucket = Bucket.Builder.create(this, "MyL2Bucket")
+            .removalPolicy(RemovalPolicy.DESTROY)
+            .build();
+    l2Bucket.with(new BucketAutoDeleteObjects());
+
+C#
+    
+    
+    
+    using Amazon.CDK;
+    using Amazon.CDK.AWS.S3;
+    
+    // Apply mixins to an L1 construct
+    var bucket = new CfnBucket(this, "MyBucket");
+    bucket.With(new BucketVersioning());
+    bucket.With(new BucketBlockPublicAccess());
+    
+    // Apply mixins to an L2 construct
+    var l2Bucket = new Bucket(this, "MyL2Bucket", new BucketProps
+    {
+        RemovalPolicy = RemovalPolicy.DESTROY
+    });
+    l2Bucket.With(new BucketAutoDeleteObjects());
+
+Go
+    
+    
+    
+    bucket := awss3.NewCfnBucket(stack, jsii.String("MyBucket"), nil)
+    bucket.With(awss3.NewBucketVersioning())
+    bucket.With(awss3.NewBucketBlockPublicAccess())
+    
+    l2Bucket := awss3.NewBucket(stack, jsii.String("MyL2Bucket"), &awss3.BucketProps{
+        RemovalPolicy: awscdk.RemovalPolicy_DESTROY,
+    })
+    l2Bucket.With(awss3.NewBucketAutoDeleteObjects())
+
+Mixins are available through the `mixins` namespace of each service module (for example, `s3.mixins`). Each mixin targets a specific resource type and is named after that resource. When you apply a mixin to an L2 construct, it automatically applies to the underlying L1 resource.
+
+For more information about Mixins, see [Mixins](./mixins.html).
+
@@ -1509 +1619 @@ CDK stages
-Environments
+Mixins