Skip to content
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

Feature/do 1609 rate limiting bypass list #1295

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/graphql-mesh-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ If notificationArn is set this construct creates a CodeStar notification rule, S
- `wafRules?`: List of custom rules
- `rateLimit?`: The limit on requests per 5-minute period. If provided, rate limiting will be enabled
- `rateLimitPriority?`: The WAF rule priority. Only used when a rateLimit value is provided (defaults to 10)
- `rateLimitBypassList?`: List of IPv4 addresses that can bypass rate limiting
- `containerInsights?`: Enable/disable container insights (defaults to true)
- `logStreamPrefix?`: Log stream prefix (defaults to 'graphql-server')
- `snsTopic?`: Optional SNS topic to subscribe all alarms to
Expand Down
25 changes: 25 additions & 0 deletions packages/graphql-mesh-server/lib/fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export interface MeshServiceProps {
* Defaults to 10
*/
rateLimitPriority?: number;
/**
* List of IPv4 addresses that can bypass rate limiting.
*/
rateLimitBypassList?: string[];
/**
* Pass custom cpu scaling steps
* Default value:
Expand Down Expand Up @@ -249,6 +253,13 @@ export class MeshService extends Construct {
this.service = fargateService.service;
this.loadBalancer = fargateService.loadBalancer;

const rateLimitBypassList = new CfnIPSet(this, "RateLimitBypassList", {
addresses: props.rateLimitBypassList || [],
ipAddressVersion: "IPV4",
scope: "REGIONAL",
description: "List of IPs that are whitelisted from rate limiting",
});

const blockedIpList = new CfnIPSet(this, "BlockedIpList", {
addresses: props.blockedIps || [],
ipAddressVersion: "IPV4",
Expand Down Expand Up @@ -312,6 +323,20 @@ export class MeshService extends Construct {
fallbackBehavior: "MATCH",
headerName: "X-Forwarded-For",
},
scopeDownStatement: {
notStatement: {
statement: {
ipSetReferenceStatement: {
arn: rateLimitBypassList.attrArn,
ipSetForwardedIpConfig: {
fallbackBehavior: "MATCH",
headerName: "X-Forwarded-For",
position: "FIRST",
},
},
},
},
},
},
},
visibilityConfig: {
Expand Down
4 changes: 4 additions & 0 deletions packages/graphql-mesh-server/lib/graphql-mesh-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export type MeshHostingProps = {
* Defaults to 10
*/
rateLimitPriority?: number;
/**
* List of IPv4 addresses that can bypass rate limiting.
*/
rateLimitBypassList?: string[];
/**
* Enable / disable container insights
* Defaults to true
Expand Down
Loading