fix: allow attaching imported capacity provider to lambda function #36758
+157
−91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reason for this change
Because the
addFunctionmethod currently only exists on theCapacityProviderconstruct, it was not possible to call it on CPs created via imports, which are only guaranteed to be of the interfaceICapacityProvider. This means the following code would fail, even though it should work:Description of changes
The change is to move the declaration of this function to be in the
ICapacityProviderinterface such that this is possible. The implementation must also be moved to theCapacityProviderBaseclass 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 callingaddFunctionon theCapacityProviderconstruct, which also extendsCapacityProviderBase. 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