Skip to main content
CDK Terrain v0.23.0 brought mixins to CDKTN projects. A mixin applies a reusable piece of behavior to one specific construct, without subclassing it.

What changed

constructs peer dependency raised to ^10.6.0

v0.23.0 raised the constructs peer dependency from ^10.4.2 to ^10.6.0 (cdk-terrain#20). constructs 10.6.0 adds the mixin primitive, and CDKTN inherits it from that library:
  • The IMixin interface, with a supports(construct) method that decides whether the mixin applies to a construct and an applyTo(construct) method that applies the change.
  • The construct.with(...mixins) method, which applies mixins to a construct immediately and returns the same construct.
If your project pins constructs below 10.6.0, raise it when you upgrade to v0.23.

No built-in mixins yet

CDKTN core does not ship ready-made mixins. You write your own, using building blocks that work with any provider, such as TerraformResource.isTerraformResource and addOverride.

Learn more

The Mixins concept page shows how to define and apply mixins, with examples. It also explains when to use a mixin instead of an Aspect.