Skip to content

RFC 814: CDK Mixins#824

Merged
mrgrain merged 9 commits intomainfrom
mrgrain/rfc-0814-cdk-mixins
Feb 12, 2026
Merged

RFC 814: CDK Mixins#824
mrgrain merged 9 commits intomainfrom
mrgrain/rfc-0814-cdk-mixins

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Oct 10, 2025

This is a request for comments about CDK Mixins: Composable Abstractions for AWS Resources. See #814 for additional details.

APIs are signed off by @rix0r.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@mrgrain mrgrain changed the title feat: CDK Mixins RFC 814: CDK Mixins Oct 10, 2025
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Nov 14, 2025
### Reason for this change

This PR implements the foundational infrastructure for the CDK Mixins framework, introducing a composable abstraction system for applying functionality to CDK constructs. It is based on the _current_ state of the [RFC](aws/aws-cdk-rfcs#824).

While the RFC is not yet approved and finalized, this PR aims to implement it including all its flaws so we can move forward with other implementing depending on this. We will update the package as the RFC evolves.

### Description of changes

**Core Framework:**
- Implemented `IMixin` interface and `Mixin` base class for creating composable abstractions
- Added `Mixins.of()` API for applying mixins to constructs with `apply()` and `mustApply()` methods
- Created `ConstructSelector` for filtering constructs by type, ID pattern, or CloudFormation resource type
- Added comprehensive error handling and validation support
- Added `.with()` augmentation to constructs for fluent mixin application

**Testing:**
- Comprehensive unit tests for core framework, selectors, and all built-in mixins
- Integration tests demonstrating real-world usage patterns
- Property manipulation utility tests including edge cases

**Documentation:**
- Updated README with usage examples, API reference, and best practices
- Added Rosetta fixture for documentation code examples

### Description of how you validated changes

- All new code is covered by unit tests
- Integration tests validate end-to-end functionality
- Rosetta fixture ensures documentation examples are valid

### 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*
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Nov 23, 2025
### Reason for this change

aws/aws-cdk-rfcs#824

CDK Mixins are composable, reusable abstractions that can be applied to any construct (L1, L2 or custom).
They are breaking down the traditional barriers between construct levels,
allowing customers to mix and match sophisticated features without being locked into specific implementations.

### Description of changes

This PR makes the package public so it can be released. It also implements some small changes based on RFC feedback.
Main functional changes are:
- Removing `validate()` in favor of just throwing errors
- Making `.with()`, `.apply()` and `.mustApply()` variadic

### Describe any new or updated permissions being added

n/a

### Description of how you validated changes

Unit tests.

### 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*
@mrgrain mrgrain self-assigned this Nov 26, 2025
@mrgrain mrgrain force-pushed the mrgrain/rfc-0814-cdk-mixins branch 2 times, most recently from bcd3aa8 to 5946909 Compare January 28, 2026 11:54
@mrgrain mrgrain force-pushed the mrgrain/rfc-0814-cdk-mixins branch from 5946909 to 7c70ca1 Compare January 28, 2026 13:57
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Jan 30, 2026
### Reason for this change

The RFC for [CDK Mixins](aws/aws-cdk-rfcs#824) was updated with several changes. This PR aligns the implementation of the preview package with the latest changes. It also includes some other API improvements to make Mixins more intuitive and consistent.

### Description of changes

- Replace `mustApply()` with separate `requireAll()` and `requireAny()` methods that set expectations before calling `apply()`. This was a change to the RFC. To support this change, this also includes:
  - New `report` getter to track successful applications, returning an array of the new `MixinApplication` interface 
  - New `selectedConstructs` getter to see which constructs were matched by the selector
- Make `.with()` silently skip unsupported constructs instead of throwing, this is implementing an RFC change
- Change `applyTo()` return type from `IConstruct` to `void` since mixins modify in place (RFC change)
- Rename `EnableVersioning` to `BucketVersioning` for consistency with other S3 mixins
- Add `BucketVersioning` constructor parameter to allow suspending versioning
- Add aws-mwaaserverless service module (wasn't committed before for some reason)
- Disable source maps in tsconfig, this aligns more with `aws-cdk-lib` which also doesn't emit sourcemaps.

### Description of how you validated changes

Updated existing unit tests to reflect the API changes and added new tests for `requireAll()`, `requireAny()`, and the `report` getter.

### 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*
@mrgrain
Copy link
Copy Markdown
Contributor Author

mrgrain commented Feb 3, 2026

This RFC is now in "Final Comments" period of 1 week.
All recent changes are available in @aws-cdk/mixins-preview v2.237.0.
One exception is an update the the execution order between Mixins and Constructs, which is not released yet.

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*
@mrgrain mrgrain merged commit d9683ef into main Feb 12, 2026
4 checks passed
@mrgrain mrgrain deleted the mrgrain/rfc-0814-cdk-mixins branch February 12, 2026 14:15
This was referenced Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants