-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(apigateway): resource policy configuration for private API #32719
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32719 +/- ##
=======================================
Coverage 81.52% 81.52%
=======================================
Files 222 222
Lines 13715 13715
Branches 2417 2417
=======================================
Hits 11181 11181
Misses 2254 2254
Partials 280 280
Flags with carried forward coverage won't be shown. Click here to find out more.
|
* | ||
* @param statement the policy statement to add | ||
*/ | ||
addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds something non-optional (a method that should be implemented compulsorily) to the interface. However, if a user has already created a custom construct that has implemented this IRestApi, this change will cause the CDK application to stop working. (It may be a Construct made in community, or it may be a Construct made within a company.)
The interface is a foundation of Construct and the medium used for communication between Constructs. So I'm wondering if we should avoid this sort of change, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review! A valid point.
As an alternative, how about having the RestApiBase
class implement the IResourceWithPolicy interface?
- export abstract class RestApiBase extends Resource implements IRestApi {
+ export abstract class RestApiBase extends Resource implements IRestApi, IResourceWithPolicy {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's maybe good!
However, RestApiBase has been exported, so there may be a slight impact. But since you've created a PR, let's just make it up and leave the rest to the maintainer's discretion!
Because I don't think many users will extend RestApiBase instead of the interface :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen most of the code yet, so please give me a shout so I can look at it when you fix it.
(I haven't submitted change request yet, so if another community reviewers see it first, I'll leave it to them! So let's not resolve these comments for now, please.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'll update my code and ping you later.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue # (if applicable)
Closes #31660.
Reason for this change
The same PR is closed during maintainer's review. (#31692)
To create a Private API Gateway, we need to attach a resource policy that allows access only from specific Interface VPC Endpoints, as shown below.
This is a bit troublesome.
Description of changes
IRestApi.addToResourcePolicy()
addToResourcePolicy()
at RestApi, SpecApi, and imported RestApi classRestApiBase.grantInvokeToVpcEndpoint()
In the
grantInvokeToVpcEndpoint
method, it was necessary to set a resource policy, and since a policy already existed in RestApiProps, I implemented it so that both can be used simultaneously.Describe any new or updated permissions being added
Add 2 functions which modify resource policies.
Description of how you validated changes
Add both unit 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