Skip to content

Conversation

@reedham-aws
Copy link
Contributor

Reason for this change

Because the addFunction method currently only exists on the CapacityProvider construct, it was not possible to call it on CPs created via imports, which are only guaranteed to be of the interface ICapacityProvider. This means the following code would fail, even though it should work:

// Function code above
const myCP = CapacityProvider.fromCapacityProviderArn(existingCPArn);
myCP.addFunction(myFn);

Description of changes

The change is to move the declaration of this function to be in the ICapacityProvider interface such that this is possible. The implementation must also be moved to the CapacityProviderBase class so that imported capacity providers, which extend this class, can make use of it. This should not break existing implementations because a) we're extending the interface and b) existing users will be calling addFunction on the CapacityProvider construct, which also extends CapacityProviderBase. The implementation itself does not need to change. The only alternatives would involve changing the way imports work, which is effectively changing the interface, something I don't want to do.

Describe any new or updated permissions being added

None

Description of how you validated changes

Added unit tests to confirm that imported CPs can use the function. Existing tests pass. I didn't add integration tests because I didn't think there was a good way to import an existing CP.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team January 21, 2026 18:04
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Jan 21, 2026
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.

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@reedham-aws
Copy link
Contributor Author

Associated issue: #36760

@reedham-aws reedham-aws force-pushed the ICapacityProvider-update branch from 7165749 to 913f2b1 Compare February 2, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants