Skip to content

Commit

Permalink
added token resolution checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Jul 25, 2023
1 parent bf947cb commit d9090d5
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Construct } from 'constructs';
import { ISecurityGroup, SubnetSelection } from '../../../aws-ec2';
import { FargateService, FargateTaskDefinition } from '../../../aws-ecs';
import { FeatureFlags } from '../../../core';
import { FeatureFlags, Token } from '../../../core';
import * as cxapi from '../../../cx-api';
import { ApplicationLoadBalancedServiceBase, ApplicationLoadBalancedServiceBaseProps } from '../base/application-load-balanced-service-base';
import { FargateServiceBaseProps } from '../base/fargate-service-base';
Expand Down Expand Up @@ -99,7 +99,13 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc
this.validateHealthyPercentage('minHealthyPercent', props.minHealthyPercent);
this.validateHealthyPercentage('maxHealthyPercent', props.maxHealthyPercent);

if (props.minHealthyPercent && props.maxHealthyPercent && props.minHealthyPercent >= props.maxHealthyPercent) {
if (
props.minHealthyPercent &&
!Token.isUnresolved(props.minHealthyPercent) &&
props.maxHealthyPercent &&
!Token.isUnresolved(props.maxHealthyPercent) &&
props.minHealthyPercent >= props.maxHealthyPercent
) {
throw new Error('Minimum healthy percent must be less than maximum healthy percent.');
}

Expand Down Expand Up @@ -132,7 +138,7 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc
* Throws an error if the specified percent is not an integer or negative.
*/
private validateHealthyPercentage(name: string, value?: number) {
if (value === undefined) { return; }
if (value === undefined || Token.isUnresolved(value)) { return; }
if (!Number.isInteger(value) || value < 0) {
throw new Error(`${name}: Must be a non-negative integer; received ${value}`);
}
Expand Down

0 comments on commit d9090d5

Please sign in to comment.