Skip to content

Commit

Permalink
feat(globalaccelerator-endpoints): Add preserveClientIp option for ne…
Browse files Browse the repository at this point in the history
…twork loadbalancer
  • Loading branch information
Sascha committed May 27, 2024
1 parent c073617 commit de87116
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/aws-cdk-lib/aws-globalaccelerator-endpoints/lib/nlb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ export interface NetworkLoadBalancerEndpointProps {
* @default 128
*/
readonly weight?: number;

/**
* Forward the client IP address in an `X-Forwarded-For` header
*
* GlobalAccelerator will create Network Interfaces in your VPC in order
* to preserve the client IP address.
*
* Client IP address preservation is supported only in specific AWS Regions.
* See the GlobalAccelerator Developer Guide for a list.
*
* @default true if available
*/
readonly preserveClientIp?: boolean;
}

/**
Expand All @@ -31,6 +44,7 @@ export class NetworkLoadBalancerEndpoint implements ga.IEndpoint {
return {
endpointId: this.loadBalancer.loadBalancerArn,
weight: this.options.weight,
clientIpPreservationEnabled: this.options.preserveClientIp,
} as ga.CfnEndpointGroup.EndpointConfigurationProperty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ test('Network Load Balancer with all properties', () => {
endpoints: [
new endpoints.NetworkLoadBalancerEndpoint(nlb, {
weight: 50,
preserveClientIp: true,
}),
],
});
Expand All @@ -84,6 +85,7 @@ test('Network Load Balancer with all properties', () => {
{
EndpointId: { Ref: 'NLB55158F82' },
Weight: 50,
ClientIPPreservationEnabled: true,
},
],
});
Expand Down

0 comments on commit de87116

Please sign in to comment.