Skip to content

Comments

feat(core): introducing CDK Mixins#37055

Open
mrgrain wants to merge 1 commit intomainfrom
mrgrain/feat/core/move-mixins-to-ga
Open

feat(core): introducing CDK Mixins#37055
mrgrain wants to merge 1 commit intomainfrom
mrgrain/feat/core/move-mixins-to-ga

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Feb 23, 2026

Reason for this change

Mixins enable composable, reusable functionality that attaches to constructs without inheritance. A mixin author implements supports() and applyTo(), and consumers apply mixins to any scope using Mixins.of(scope).apply(myMixin). Construct selectors narrow the target set by resource type, path pattern, or ID glob. This composability is the key differentiator from Aspects: where Aspects visit every node in the tree, Mixins give authors fine-grained control over which constructs receive which behavior.

Description of changes

The core Mixins types (Mixins, Mixin, IMixin, MixinApplicator, ConstructSelector, and related interfaces) now live in @aws-cdk-lib/core/lib. The MIXIN_SYMBOL identifier changes from the preview value to @aws-cdk/core.Mixin, which deliberately breaks cross-version compatibility checks so that preview mixins and GA mixins remain distinct.

The @aws-cdk/mixins-preview package re-exports these types from aws-cdk-lib/core instead of bundling its own copies. Existing code that imports from @aws-cdk/mixins-preview continues to work without changes. The preview package keeps its additional features like built-in mixins and EventBridge event patterns.

A new "Mixins" section in the aws-cdk-lib README documents the Mixins.of() entry point, custom mixin creation, construct selection, and error handling with requireAny() / requireAll(). It sits right before the existing "Aspects" section because the two features are conceptually related.

Analytics metadata tracks mixin usage via aws:cdk:analytics:mixin node metadata. The FQN of first-party mixins (those with allowed package prefixes) is recorded; third-party or unidentified mixins are redacted to *.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

aws-cdk-lib compiles cleanly with tsc --noEmit. Unit tests cover the Mixin base class, MixinApplicator (including requireAny/requireAll semantics and ordering guarantees), ConstructSelector variants, and metadata recording with FQN redaction.

Checklist


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

@mrgrain mrgrain requested a review from a team as a code owner February 23, 2026 11:24
@github-actions github-actions bot added the p2 label Feb 23, 2026
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 23, 2026
@mrgrain mrgrain changed the title feat(core): move Mixins mechanism to aws-cdk-lib for GA feat(core): GA Mixins mechanism in aws-cdk-lib Feb 23, 2026
@mrgrain mrgrain changed the title feat(core): GA Mixins mechanism in aws-cdk-lib feat(core): introducing CDK Mixins Feb 23, 2026
Move the core Mixins mechanism (Mixins, Mixin, IMixin, MixinApplicator,
ConstructSelector) from @aws-cdk/mixins-preview to aws-cdk-lib/core.
@mrgrain mrgrain force-pushed the mrgrain/feat/core/move-mixins-to-ga branch from 3a582c9 to 3933a40 Compare February 23, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant