Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public scaleOnUtilization(props: UtilizationScalingProps) {
if (props.targetUtilizationPercent < 10 || props.targetUtilizationPercent > 90) {
// tslint:disable-next-line:max-line-length
throw new RangeError(`targetUtilizationPercent for DynamoDB scaling must be between 10 and 90 percent, got: ${props.targetUtilizationPercent}`);
}
const predefinedMetric = this.props.dimension.indexOf('ReadCapacity') === -1
? appscaling.PredefinedMetric.DYANMODB_WRITE_CAPACITY_UTILIZATION
: appscaling.PredefinedMetric.DYNAMODB_READ_CAPACITY_UTILIZATION;
super.doScaleToTrackMetric('Tracking', {
policyName: props.policyName,
disableScaleIn: props.disableScaleIn,
scaleInCooldown: props.scaleInCooldown,
scaleOutCooldown: props.scaleOutCooldown,
targetValue: props.targetUtilizationPercent,
predefinedMetric,
});
}
}
public scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps) {
return super.doScaleToTrackMetric(id, {
predefinedMetric: appscaling.PredefinedMetric.ECS_SERVICE_AVERAGE_CPU_UTILIZATION,
policyName: props.policyName,
disableScaleIn: props.disableScaleIn,
targetValue: props.targetUtilizationPercent,
scaleInCooldown: props.scaleInCooldown,
scaleOutCooldown: props.scaleOutCooldown
});
}