Skip to content

feat: property injection for 122 constructs #33887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
May 5, 2025
Merged

Conversation

pcheungamz
Copy link
Contributor

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


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 March 24, 2025 13:10
@github-actions github-actions bot added the p2 label Mar 24, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 24, 2025 13:10
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Mar 24, 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
Copy link
Contributor Author

This is a preliminary PR to get early review on core/lib/prop-injectors.ts and core/test/prop-injectors.test.ts.

TODOs:

  • remove debug logging.
  • enable property injection on more Constructs

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

2 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Exciting!

A lot of work in here applying these changes to all of those constructs, thanks!

Copy link
Contributor

@moelasmar moelasmar left a comment

Choose a reason for hiding this comment

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

thanks @pcheungamz for implementing this feature .. I have some questions/comments about the L2 updates you did
1- Did you update all L2 constructs, and if yes, I assume you did not do it manually, if also yes, can I ask to push this script to be used as a GH action, so for future L2s, this change will be automatically applied.
2- Can you update the aws-cdk-lib/Readme file to add a new section explaining how this feature should be used. I believe we will also need some documentation updates to the CDK Docs
3- Can you add some integration test cases to https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk-testing/framework-integ/test/core/test

@moelasmar moelasmar added pr/do-not-merge This PR should not be merged at this time. and removed pr/do-not-merge This PR should not be merged at this time. labels Apr 3, 2025
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

2 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 1, 2025
@pcheungamz
Copy link
Contributor Author

pcheungamz commented May 2, 2025

This PR will make all L2 Constructs property injectable in the future: #34328. But it shouldn't block this PR.

rix0rrr
rix0rrr previously approved these changes May 5, 2025
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Shipped then!

Copy link
Contributor

mergify bot commented May 5, 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).

Copy link
Contributor

mergify bot commented May 5, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify mergify bot dismissed rix0rrr’s stale review May 5, 2025 12:57

Pull request has been modified.

Copy link
Contributor

mergify bot commented May 5, 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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: fa0d021
  • 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 5, 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 89ff945 into aws:main May 5, 2025
13 of 15 checks passed
Copy link
Contributor

github-actions bot commented May 5, 2025

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 5, 2025
@pcheungamz pcheungamz deleted the prop-injectors branch May 6, 2025 12:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants