Skip to content

Commit

Permalink
Update packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/applic…
Browse files Browse the repository at this point in the history
…ation-target-group.ts

Co-authored-by: Luca Pizzini <lpizzini7@gmail.com>
  • Loading branch information
mazyu36 and lpizzinidev authored Jun 14, 2024
1 parent 4e27419 commit 14bb6a9
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,11 @@ export class ApplicationTargetGroup extends TargetGroupBase implements IApplicat
}
this.addTarget(...(props.targets || []));

if (!Token.isUnresolved(props.enableAnomalyMitigation) &&
(props.enableAnomalyMitigation !== undefined)) {

if (props.enableAnomalyMitigation) {
if (isWeightedRandomAlgorithm) {
this.setAttribute('load_balancing.algorithm.anomaly_mitigation', 'on');
} else {
throw new Error('Anomaly mitigation is only available when `loadBalancingAlgorithmType` is `TargetGroupLoadBalancingAlgorithmType.WEIGHTED_RANDOM`.');
}
} else {
this.setAttribute('load_balancing.algorithm.anomaly_mitigation', 'off');
if (props.enableAnomalyMitigation !== undefined) {
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');
}
}

Expand Down

0 comments on commit 14bb6a9

Please sign in to comment.