-
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): rate limited API key #6509
Conversation
… at api key level In cases when we need to configure throttling and quotas etc., at the api key level, we need to create a usage plan for the api key and link the two. This commit introduces a construct which allows the user to create an api key and spicify rate limiting settings, while creating the api key and not worry about creating usage plan and linking the two. fixes aws#6405
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
… at api key level In cases when we need to configure throttling and quotas etc., at the api key level, we need to create a usage plan for the api key and link the two. This commit introduces a construct which allows the user to create an api key and spicify rate limiting settings, while creating the api key and not worry about creating usage plan and linking the two. fixes aws#6405
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
… at api key level In cases when we need to configure throttling and quotas etc., at the api key level, we need to create a usage plan for the api key and link the two. This commit introduces a construct which allows the user to create an api key and spicify rate limiting settings, while creating the api key and not worry about creating usage plan and linking the two. fixes aws#6405
… at api key level In cases when we need to configure throttling and quotas etc., at the api key level, we need to create a usage plan for the api key and link the two. This commit introduces a construct which allows the user to create an api key and spicify rate limiting settings, while creating the api key and not worry about creating usage plan and linking the two. fixes aws#6405
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -20,6 +20,7 @@ export interface IApiKey extends IResourceBase { | |||
*/ | |||
export interface ApiKeyProps extends ResourceOptions { | |||
/** | |||
* [disable-awslint:ref-via-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.
Why is this needed? We generally don't encourage any new linter exclusions.
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.
The build was failing after I made RateLimitedApiKeyProps extend ApiKeyProps :
error: [awslint:ref-via-interface:@aws-cdk/aws-apigateway.RateLimitedApiKeyProps.resources] API should use interface and not the concrete class (@aws-cdk/aws-apigateway.RestApi). If this is intentional, add "[disable-awslint:ref-via-interface]" to element's jsdoc
So I followed the suggestion and added [disable-awslint:ref-via-interface]
to the jsdoc of resources
property in ApiKeyProps
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 see it now.
I believe this is occurring because this object is using RestApi
instead of IRestApi
as the type for resources
.
Can we try switching it to IRestApi
and see if all tests still pass?
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 tried doing that, but it resulted in compilation errors as renderStageKeys
method expects resources
to be of type RestApi
and changing it to IRestApi
is not possible as it doesn't have deploymentStage
property needed by this method
https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-apigateway/lib/api-key.ts#L90-L101
Co-Authored-By: Niranjan Jayakar <[email protected]>
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
… at api key level Incorporates changes from code review.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -20,6 +20,7 @@ export interface IApiKey extends IResourceBase { | |||
*/ | |||
export interface ApiKeyProps extends ResourceOptions { | |||
/** | |||
* [disable-awslint:ref-via-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 see it now.
I believe this is occurring because this object is using RestApi
instead of IRestApi
as the type for resources
.
Can we try switching it to IRestApi
and see if all tests still pass?
/** | ||
* RateLimitedApiKey properties. | ||
*/ | ||
export interface RateLimitedApiKeyProps extends ApiKeyProps { |
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.
Missed something from last time. We usually don't extend one Props class from another Props class.
The following changes are needed here
- Rename
ApiKeyProps
toApiKeyOptions
- Create a new empty
ApiKeyProps
class -export interface ApiKeyProps extends ApiKeyOptions { }
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.
Not sure if I understand.
Is the suggestion to :
- Rename
ApiKeyProps
defined inApiKey
, toApiKeyOptions
- Create an empty interface (
ApiKeyProps
) inRateLimitedApiKey
extendingApiKeyOptions
- Use it like
export interface RateLimitedApiKeyProps extends ApiKeyProps {
If that's the case, I'm confused how it will help/is better
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.
You're correct. I think I was looking for an optimization/future-proofing whose value is unclear yet. Ignore this.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Commit Message
feat(apigateway): rate limited API key (#6509)
In cases when we need to configure throttling and quotas etc., at the api key level, we need to create a usage plan for the api key and link the two.
This commit introduces a construct which allows the user to create an api key and spicify rate limiting settings, while creating the api key and not worry about creating usage plan and linking the two.
fixes #6405
End Commit Message
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license