From 398b91d4c13790c3c58efb35170edb695e05f26a Mon Sep 17 00:00:00 2001 From: maz Date: Sat, 15 Jun 2024 12:21:03 +0900 Subject: [PATCH] fix: incorporate review comments --- packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md | 1 + .../lib/alb/application-target-group.ts | 4 +--- .../aws-elasticloadbalancingv2/test/alb/listener.test.ts | 2 +- .../aws-elasticloadbalancingv2/test/alb/target-group.test.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md index 9bf2fd445c15e..86f27dcb43ef0 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md @@ -474,6 +474,7 @@ const tg = new elbv2.ApplicationTargetGroup(this, 'TargetGroup', { loadBalancingAlgorithmType: elbv2.TargetGroupLoadBalancingAlgorithmType.WEIGHTED_RANDOM, enableAnomalyMitigation: true, }); +``` ## Using Lambda Targets diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts index 94896dbe17931..00b7f1fed48c0 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-target-group.ts @@ -367,13 +367,11 @@ export class ApplicationTargetGroup extends TargetGroupBase implements IApplicat this.addTarget(...(props.targets || [])); if (props.enableAnomalyMitigation !== undefined) { - if (props.enableAnomalyMitigation && isWeightedRandomAlgorithm) { + if (props.enableAnomalyMitigation && !isWeightedRandomAlgorithm) { throw new Error('Anomaly mitigation is only available when `loadBalancingAlgorithmType` is `TargetGroupLoadBalancingAlgorithmType.WEIGHTED_RANDOM`.'); } this.setAttribute('load_balancing.algorithm.anomaly_mitigation', props.enableAnomalyMitigation ? 'on' : 'off'); - } } - } } diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/listener.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/listener.test.ts index 31cca61fc3eeb..4c59f89c674d5 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/listener.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/listener.test.ts @@ -1861,7 +1861,7 @@ describe('tests', () => { }); }); - test('Can add targets with weight_random algorithm and anomaly mitigation disabled, () => { + test('Can add targets with weight_random algorithm and anomaly mitigation disabled', () => { // GIVEN const app = new cdk.App(); const stack = new cdk.Stack(app, 'Stack'); diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts index 1614ac921a363..89ea4c45d2f0e 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts @@ -742,7 +742,7 @@ describe('tests', () => { }); }); - test('weight_random algorithm and anomaly mitigation is disabled, () => { + test('weight_random algorithm and anomaly mitigation is disabled', () => { // GIVEN const app = new cdk.App(); const stack = new cdk.Stack(app, 'Stack');