AWS CDK v2.196.0 introduced Property Injection, a feature that automatically applies default configuration properties to CDK constructs without modifying existing code. It solves the problem of configuration drift and compliance gaps in large organizations by intercepting construct creation and merging organizational defaults with developer-specified properties. The post explains how to implement the IPropertyInjector interface, register injectors at different scope levels (App, Stage, Stack), and compares Property Injection to custom L2 constructs. Key limitations include: it acts as defaults not enforcement (developers can override), it only works with L2 constructs, and it requires CDK v2.196.0+. For strict compliance, it should be combined with CDK Aspects or AWS Config rules.
Table of contents
The Challenge of Infrastructure StandardizationIntroducing Property InjectionUnderstanding the Implementation ApproachProperty Injection vs L2 ConstructsImplementation ComparisonKey DifferencesWhen to Choose Each ApproachImplementation PatternsBest PracticesLimitations and ConsiderationsConclusionSort: