feat(mixin): add IMixin interface and Construct.with() method#2843
Merged
feat(mixin): add IMixin interface and Construct.with() method#2843
Conversation
rix0rrr
reviewed
Feb 2, 2026
Implements the constructs package parts of RFC-0814 (CDK Mixins). Adds the `IMixin` interface with `supports()` and `applyTo()` methods, and the `with()` method on `Construct` and `IConstruct` for fluent mixin application across construct trees.
6e13154 to
87dcc0b
Compare
rix0rrr
approved these changes
Feb 2, 2026
1 task
mergify bot
pushed a commit
to aws/aws-cdk
that referenced
this pull request
Feb 3, 2026
### Issue # (if applicable) Related RFC: aws/aws-cdk-rfcs#824 ### Reason for this change Aligns the implementation with the latest version of the [Mixins RFC](aws/aws-cdk-rfcs#824). The `.with()` method previously iterated over constructs first, then mixins. This meant that mixins were not guaranteed to be applied in the order they were passed to the method. Additionally, if a mixin added new constructs to the tree, subsequent mixins in the same call could unexpectedly visit those newly added constructs. ### Description of changes Changed the loop order so that mixins are applied in order. The list of constructs is now captured at the start of the call, ensuring that constructs added by a mixin will not be visited by subsequent mixins. Users who need subsequent mixins to apply to added constructs can use multiple `.with()` calls. Also improved variable naming for clarity (`c` → `construct`, `m` → `mixin`). ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Existing tests pass. This behavior is explicitly tested in aws/constructs#2843. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
aemada-aws
pushed a commit
to aemada-aws/aws-cdk
that referenced
this pull request
Feb 11, 2026
### Issue # (if applicable) Related RFC: aws/aws-cdk-rfcs#824 ### Reason for this change Aligns the implementation with the latest version of the [Mixins RFC](aws/aws-cdk-rfcs#824). The `.with()` method previously iterated over constructs first, then mixins. This meant that mixins were not guaranteed to be applied in the order they were passed to the method. Additionally, if a mixin added new constructs to the tree, subsequent mixins in the same call could unexpectedly visit those newly added constructs. ### Description of changes Changed the loop order so that mixins are applied in order. The list of constructs is now captured at the start of the call, ensuring that constructs added by a mixin will not be visited by subsequent mixins. Users who need subsequent mixins to apply to added constructs can use multiple `.with()` calls. Also improved variable naming for clarity (`c` → `construct`, `m` → `mixin`). ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Existing tests pass. This behavior is explicitly tested in aws/constructs#2843. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This was referenced Feb 17, 2026
github-merge-queue bot
pushed a commit
to projen/projen
that referenced
this pull request
Feb 20, 2026
The default version of the `constructs` library for CDK 2.x projects has been stuck at `10.0.5` since CDK 2 was first introduced. Bumping the default to `10.5.1` enables support for CDK Mixins out of the box. Constructs `10.5.0` introduced the `IMixin` interface and `Construct.with()` method (aws/constructs#2843), allowing newly created projects to use this feature without manually upgrading their constructs dependency. Additionally, the default for `cdkVersion` is updated to `2.189.1`, which is the oldest CDK version without a published security advisory. This makes it a suitable minimum version for CDK Construct Libraries. Only affects new projects, which will now be created by putting this version into the generated projen RC file. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-merge-queue bot
pushed a commit
to projen/projen
that referenced
this pull request
Feb 20, 2026
The default version of the `constructs` library for CDK 2.x projects has been stuck at `10.0.5` since CDK 2 was first introduced. Bumping the default to `10.5.1` enables support for CDK Mixins out of the box. Constructs `10.5.0` introduced the `IMixin` interface and `Construct.with()` method (aws/constructs#2843), allowing newly created projects to use this feature without manually upgrading their constructs dependency. Additionally, the default for `cdkVersion` is updated to `2.189.1`, which is the oldest CDK version without a published security advisory. This makes it a suitable minimum version for CDK Construct Libraries. Only affects new projects, which will now be created by putting this version into the generated projen RC file. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the
constructspackage parts of RFC-0814: CDK Mixins.CDK Mixins are composable, reusable abstractions that can be applied to any construct. This change adds the foundational support to the
constructslibrary, enabling the fluent.with()API described in the RFC.Changes
The
IMixininterface defines the contract for mixins with two methods:supports(construct)- determines if a mixin can be applied to a given constructapplyTo(construct)- applies the mixin functionality to the targetThe
with()method is added toConstructandIConstruct, allowing mixins to be applied fluently. When called, it traverses the construct tree and applies each mixin to all supported constructs.Why
Mixins are a new way to build abstractions, that does not rely on the construct level approach many implementors use. They allow users to employ a mix and match approach for features that doesn't lock consumers into specific implementations.