Skip to content

Conversation

pcheungamz
Copy link
Contributor

Reason for this change

This implements this RFC: https://github.com/aws/aws-cdk-rfcs/blob/main/text/0693-property-injection.md

Description of changes

This PR contains these changes:

  • 122 Constructs that are decorated with propertyInjectable.
  • App, Stage, and Stack can specify propertyInjectors - a list of IPropertyInjector
  • Logic to find the correct Construct Property Injector during instantiation.
  • ConstructsUpdater makes all L2 Constructs propertyInjectable.
  • Add a test case showing Property Injectors applied to an L2 Construct inherited from another L2 Construct.

Describe any new or updated permissions being added

No new IAM permission.

Description of how you validated changes

Added unit tests and integ tests.

Checklist


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

pcheungamz added 3 commits May 9, 2025 20:43
### Issue # (if applicable)

This Implements the Property Injectors RFC.  https://github.com/aws/aws-cdk-rfcs/blob/main/text/0693-property-injection.md

### Reason for this change

Implement the Property Injectors feature so orgs can set up default Construct props values.

### Description of changes

Key changes:
* propertyInjectionDecorator to make a Construct Property Injectable.
* applyInjectors is called from Construct's constructor to inject property defaults.
* IPropertyInjector defines an Property Injector.
* PropertyInjectors class that stores the map of Constructs to Injectors.
* App, Stage, and Stack now has a new propertyInjectors property.

### Describe any new or updated permissions being added


None

### Description of how you validated changes

* Unit test in core/test/prop-injectors.test.ts
* Use `yarn package --target js` to create a library and write Injectors for Constructs.

### Checklist
- [ ] 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*
…#34328)

### Issue # (if applicable)

This is a followup to aws#33887.

DO NOT merge this PR until after 33887 is merged.

### Reason for this change

In the original Property Injection PR, we enabled 122 Constructs for Property Injections, but we want to make this feature available for all L2 Constructs.

### Description of changes

Add logic to Constructs ConstructsUpdater to if a Construct already have PROPERTY_INJECTION_ID property.  If not, it will:
- Add PROPERTY_INJECTION_ID with value that is calculated from path and class name
- Import aws-cdk-lib/core/lib/prop-injectable
- Add class decorator @propertyInjectable

### Describe any new or updated permissions being added

No permission change.

### Description of how you validated changes

- Added unit tests and ran `npm test`
- Ran `./bin/update-construct-metadata` locally and manually verified a few random files.

### Checklist
- [ ] 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*
@pcheungamz pcheungamz requested a review from a team as a code owner May 11, 2025 19:47
@aws-cdk-automation aws-cdk-automation requested a review from a team May 11, 2025 19:47
@github-actions github-actions bot added repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK p2 labels May 11, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@pcheungamz pcheungamz changed the title feat: Property Injectors feat: property injectors May 11, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 11, 2025 20:08

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 11, 2025
@pcheungamz pcheungamz changed the title feat: property injectors feat: property injectors and make all L2 Constructors injectable May 12, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 12, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 171649c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented May 13, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 4dc523f into aws:main May 13, 2025
14 of 16 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2025
@pcheungamz pcheungamz deleted the inherit branch May 13, 2025 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants